• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java IllegalAnnotationError类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中org.kohsuke.args4j.IllegalAnnotationError的典型用法代码示例。如果您正苦于以下问题:Java IllegalAnnotationError类的具体用法?Java IllegalAnnotationError怎么用?Java IllegalAnnotationError使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

IllegalAnnotationError类属于org.kohsuke.args4j包,在下文中一共展示了IllegalAnnotationError类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: parseAdditionalOptions

点赞 2

import org.kohsuke.args4j.IllegalAnnotationError; //导入依赖的package包/类
private void parseAdditionalOptions(Object bean, Set<Object> parsedBeans) {
  for (Class<?> c = bean.getClass(); c != null; c = c.getSuperclass()) {
    for (Field f : c.getDeclaredFields()) {
      if (f.isAnnotationPresent(Options.class)) {
        Object additionalBean = null;
        try {
          additionalBean = f.get(bean);
        } catch (IllegalAccessException e) {
          throw new IllegalAnnotationError(e);
        }
        parseWithPrefix(f.getAnnotation(Options.class).prefix(), additionalBean, parsedBeans);
      }
    }
  }
}
 

开发者ID:gerrit-review,
项目名称:gerrit,
代码行数:16,
代码来源:CmdLineParser.java

示例2: getListStrings

点赞 2

import org.kohsuke.args4j.IllegalAnnotationError; //导入依赖的package包/类
private List<IndependentPair<String, Class<?>>> getListStrings() throws IllegalArgumentException, IllegalAccessException {
	Object o = f.get(bean);
       if(o==null) {
           return new ArrayList<IndependentPair<String, Class<?>>>();
       }
       if(!(o instanceof List))
           throw new IllegalAnnotationError(Messages.ILLEGAL_FIELD_SIGNATURE.format(f));
       ArrayList<IndependentPair<String, Class<?>>> ret = new ArrayList<IndependentPair<String, Class<?>>>();
       for(Object obj : (List<?>) o){
       	Class<?> objClass = obj.getClass();
       	ret.add(new IndependentPair<String, Class<?>>(obj.toString(), objClass));
       }
       return ret;
}
 

开发者ID:openimaj,
项目名称:openimaj,
代码行数:15,
代码来源:MultiValueFieldGetter.java

示例3: getListStrings

点赞 2

import org.kohsuke.args4j.IllegalAnnotationError; //导入依赖的package包/类
private List<IndependentPair<String, Class<?>>> getListStrings() throws IllegalArgumentException, IllegalAccessException {
	Object o = f.get(bean);
       if(o==null) {
           return new ArrayList<IndependentPair<String, Class<?>>>();
       }
       if(!(o instanceof Map))
           throw new IllegalAnnotationError(Messages.ILLEGAL_FIELD_SIGNATURE.format(f));
       ArrayList<IndependentPair<String, Class<?>>> ret = new ArrayList<IndependentPair<String, Class<?>>>();
       for(Entry<?, ?> obj : ((Map<?,?>) o).entrySet()){
       	Class<?> objClass = Object.class;
       	IndependentPair<String, Class<?>> pair = new IndependentPair<String, Class<?>>(obj.getKey().toString() + "=" + obj.getValue().toString(),objClass);
       	ret.add(pair);
       }
       return ret;
}
 

开发者ID:openimaj,
项目名称:openimaj,
代码行数:16,
代码来源:MapGetter.java

示例4: parseAdditionalOptions

点赞 2

import org.kohsuke.args4j.IllegalAnnotationError; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void parseAdditionalOptions(ClassParser classParser, Object bean, Set<Class<?>> visited) {
  // The top-level bean was already parsed by the superclass constructor,
  // so an empty visited set means we're parsing the top-level bean.
  if (!visited.isEmpty()) {
    classParser.parse(bean, this); // 'Parse' the class of the bean looking for annotations.
  }
  Class<?> beanClass = bean.getClass();
  if (visited.contains(beanClass)) {
    throw new IllegalAnnotationError(beanClass.getCanonicalName() + " used more than once.");
  } else {
    visited.add(beanClass);
  }

  for (Field f : beanClass.getDeclaredFields()) {
    if (f.isAnnotationPresent(AdditionalOptions.class)) {
      try {
        // TODO(user): nicer to do this lazily in parseArgument()
        Object fieldValue = f.getType().newInstance();
        Setters.create(f, bean).addValue(fieldValue);
        parseAdditionalOptions(classParser, fieldValue, visited);
      } catch (Exception e) {
        throw Throwables.propagate(e);
      }
    }
  }
}
 

开发者ID:saleehk,
项目名称:buck-cutom,
代码行数:28,
代码来源:CmdLineParserAdditionalOptions.java

示例5: parseAdditionalOptions

点赞 2

import org.kohsuke.args4j.IllegalAnnotationError; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void parseAdditionalOptions(ClassParser classParser, Object bean, Set<Class<?>> visited) {
  // The top-level bean was already parsed by the superclass constructor,
  // so an empty visited set means we're parsing the top-level bean.
  if (!visited.isEmpty()) {
    classParser.parse(bean, this); // 'Parse' the class of the bean looking for annotations.
  }
  Class<?> beanClass = bean.getClass();
  if (visited.contains(beanClass)) {
    throw new IllegalAnnotationError(beanClass.getCanonicalName() + " used more than once.");
  } else {
    visited.add(beanClass);
  }

  for (Field f : beanClass.getDeclaredFields()) {
    if (f.isAnnotationPresent(AdditionalOptions.class)) {
      try {
        // TODO(vlada): nicer to do this lazily in parseArgument()
        Object fieldValue = f.getType().newInstance();
        Setters.create(f, bean).addValue(fieldValue);
        parseAdditionalOptions(classParser, fieldValue, visited);
      } catch (CmdLineException | IllegalAccessException | InstantiationException e) {
        throw new RuntimeException(e);
      }
    }
  }
}
 

开发者ID:facebook,
项目名称:buck,
代码行数:28,
代码来源:AdditionalOptionsCmdLineParser.java

示例6: testDuplicateAdditionalOptionsClass

点赞 2

import org.kohsuke.args4j.IllegalAnnotationError; //导入依赖的package包/类
@Test(expected = IllegalAnnotationError.class)
public void testDuplicateAdditionalOptionsClass() {
    new CmdLineParserAdditionalOptions(new DuplicateOptions());
}
 

开发者ID:saleehk,
项目名称:buck-cutom,
代码行数:5,
代码来源:CmdLineParserAdditionalOptionsTest.java

示例7: testRecursiveAdditionalOptions

点赞 2

import org.kohsuke.args4j.IllegalAnnotationError; //导入依赖的package包/类
@Test(expected = IllegalAnnotationError.class)
public void testRecursiveAdditionalOptions() {
    new CmdLineParserAdditionalOptions(new InfiniteOptions());
}
 

开发者ID:saleehk,
项目名称:buck-cutom,
代码行数:5,
代码来源:CmdLineParserAdditionalOptionsTest.java

示例8: testDuplicateAdditionalOptionsClass

点赞 2

import org.kohsuke.args4j.IllegalAnnotationError; //导入依赖的package包/类
@Test(expected = IllegalAnnotationError.class)
public void testDuplicateAdditionalOptionsClass() {
  new AdditionalOptionsCmdLineParser(new DuplicateOptions());
}
 

开发者ID:facebook,
项目名称:buck,
代码行数:5,
代码来源:AdditionalOptionsCmdLineParserTest.java

示例9: testRecursiveAdditionalOptions

点赞 2

import org.kohsuke.args4j.IllegalAnnotationError; //导入依赖的package包/类
@Test(expected = IllegalAnnotationError.class)
public void testRecursiveAdditionalOptions() {
  new AdditionalOptionsCmdLineParser(new InfiniteOptions());
}
 

开发者ID:facebook,
项目名称:buck,
代码行数:5,
代码来源:AdditionalOptionsCmdLineParserTest.java

示例10: CmdLineParser

点赞 1

import org.kohsuke.args4j.IllegalAnnotationError; //导入依赖的package包/类
/**
 * Creates a new command line owner that parses arguments/options and set them into the given
 * object.
 *
 * @param bean instance of a class annotated by {@link org.kohsuke.args4j.Option} and {@link
 *     org.kohsuke.args4j.Argument}. this object will receive values.
 * @throws IllegalAnnotationError if the option bean class is using args4j annotations
 *     incorrectly.
 */
@Inject
public CmdLineParser(OptionHandlers handlers, @Assisted final Object bean)
    throws IllegalAnnotationError {
  this.handlers = handlers;
  this.parser = new MyParser(bean);
}
 

开发者ID:gerrit-review,
项目名称:gerrit,
代码行数:16,
代码来源:CmdLineParser.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)