tempArity = Range.valueOf("1"); tempArity = tempArity.unspecified(true);
/** Returns the default arity {@code Range} for {@link Option options}: booleans have arity 0, other types have arity 1. * @param type the type whose default arity to return * @return a new {@code Range} indicating the default arity of the specified type * @deprecated use {@link #defaultArity(Field)} instead */ @Deprecated public static Range defaultArity(Class<?> type) { return isBoolean(type) ? Range.valueOf("0").unspecified(true) : Range.valueOf("1").unspecified(true); } private int size() { return 1 + max - min; }
private static Range defaultArity(IAnnotatedElement member) { ITypeInfo info = member.getTypeInfo(); if (member.isAnnotationPresent(Option.class)) { boolean zeroArgs = info.isBoolean() || (info.isMultiValue() && info.getAuxiliaryTypeInfos().get(0).isBoolean()); return zeroArgs ? Range.valueOf("0").unspecified(true) : Range.valueOf("1").unspecified(true); } if (info.isMultiValue()) { return Range.valueOf("0..1").unspecified(true); } return Range.valueOf("1").unspecified(true);// for single-valued fields (incl. boolean positional parameters) } /** Returns the default arity {@code Range} for {@link Option options}: booleans have arity 0, other types have arity 1.
tempArity = Range.valueOf("1"); tempArity = tempArity.unspecified(true);
private static Range defaultArity(TypedMember member) { Class<?> type = member.getType(); if (member.isAnnotationPresent(Option.class)) { Class<?>[] typeAttribute = ArgsReflection .inferTypes(type, member.getAnnotation(Option.class).type(), member.getGenericType()); boolean zeroArgs = isBoolean(type) || (isMultiValue(type) && isBoolean(typeAttribute[0])); return zeroArgs ? Range.valueOf("0").unspecified(true) : Range.valueOf("1").unspecified(true); } if (isMultiValue(type)) { return Range.valueOf("0..1").unspecified(true); } return Range.valueOf("1").unspecified(true);// for single-valued fields (incl. boolean positional parameters) } /** Returns the default arity {@code Range} for {@link Option options}: booleans have arity 0, other types have arity 1.
/** Returns the default arity {@code Range} for {@link Option options}: booleans have arity 0, other types have arity 1. * @param type the type whose default arity to return * @return a new {@code Range} indicating the default arity of the specified type * @deprecated use {@link #defaultArity(Field)} instead */ @Deprecated public static Range defaultArity(Class<?> type) { return isBoolean(type) ? Range.valueOf("0").unspecified(true) : Range.valueOf("1").unspecified(true); } private int size() { return 1 + max - min; }
private ITypeInfo createTypeInfo(Class<?> type, Type genericType) { Range arity = null; if (isOption()) { arity = Range.valueOf(getAnnotation(Option.class).arity()); } if (isParameter()) { arity = Range.valueOf(getAnnotation(Parameters.class).arity()); } if (arity == null || arity.isUnspecified) { if (isOption()) { arity = (type == null || isBoolean(type)) ? Range.valueOf("0") : Range.valueOf("1"); } else { arity = Range.valueOf("1"); } arity = arity.unspecified(true); } return RuntimeTypeInfo.create(type, annotationTypes(), genericType, arity, (isOption() ? boolean.class : String.class)); }