private static Object[] checkElementsNotNull(Object[] objects) { for (Object object : objects) { Preconditions.checkNotNull(object); } return objects; }
private static Object[] checkElementsNotNull(Object[] objects) { for (Object object : objects) { Preconditions.checkNotNull(object); } return objects; }
@Override public int indexOf(Object o) { Preconditions.checkNotNull(o); for (int i = 0; i < elements.length; i++) { if (o.equals(elements[i])) { return i; } } return -1; }
/** * @param declaringClass * @return the ordered list of declared methods for the given class */ public static List<Method> getDeclaredMethods(Class<?> declaringClass) { Preconditions.checkNotNull(declaringClass); List<Method> declaredMethods = Arrays.asList(SecurityActions.getDeclaredMethods(declaringClass)); Collections.sort(declaredMethods, METHOD_COMPARATOR_INSTANCE); return declaredMethods; }
/** * Creates an immutable list that consists of the given elements. This method should only be used in the varargs form. If there is a need to create an * immutable list of an array of elements, {@link #copyOf(Object[])} should be used instead. * * @param elements the given elements * @return an immutable list */ @SafeVarargs public static <T> List<T> of(T... elements) { Preconditions.checkNotNull(elements); return ofInternal(elements); }
/** * @param declaringClass * @return the ordered list of declared constructors for the given class */ public static List<Constructor<?>> getDeclaredConstructors(Class<?> declaringClass) { Preconditions.checkNotNull(declaringClass); List<Constructor<?>> declaredConstructors = Arrays.asList(SecurityActions.getDeclaredConstructors(declaringClass)); Collections.sort(declaredConstructors, CONSTRUCTOR_COMPARATOR_INSTANCE); return declaredConstructors; }
Singleton(Set<T> set) { Preconditions.checkNotNull(set); Preconditions.checkArgument(set.size() == 1, set); this.element = set.iterator().next(); }
/** * Creates an immutable list that consists of the given elements. This method should only be used in the varargs form. If there is a need to create * an immutable list of an array of elements, {@link #copyOf(Object[])} should be used instead. * * @param elements the given elements * @return an immutable list */ @SafeVarargs public static <T> List<T> of(T... elements) { Preconditions.checkNotNull(elements); return ofInternal(elements); }
Doubleton(Set<T> set) { Preconditions.checkNotNull(set); Preconditions.checkArgument(set.size() == 2, set); Iterator<T> iterator = set.iterator(); element1 = iterator.next(); element2 = iterator.next(); }
Singleton(Set<T> set) { Preconditions.checkNotNull(set); Preconditions.checkArgument(set.size() == 1, set); this.element = set.iterator().next(); }
/** * Creates an immutable list that consists of the given elements. This method should only be used in the varargs form. If there is a need to create * an immutable list of an array of elements, {@link #copyOf(Object[])} should be used instead. * * @param elements the given elements * @return an immutable list */ @SafeVarargs public static <T> List<T> of(T... elements) { Preconditions.checkNotNull(elements); return ofInternal(elements); }
Doubleton(Set<T> set) { Preconditions.checkNotNull(set); Preconditions.checkArgument(set.size() == 2, set); Iterator<T> iterator = set.iterator(); element1 = iterator.next(); element2 = iterator.next(); }
/** * @param field * @return the index for the given field */ public static int getIndexForField(Field field) { Preconditions.checkNotNull(field); return getIndexForMember(field, getDeclaredFields(field.getDeclaringClass())); }
/** * Creates an immutable list that consists of the elements in the given array. A copy of the given array is used which means * that any modifications to the given array will not affect the immutable list. * * @param elements the given array of elements * @return an immutable list */ public static <T> List<T> copyOf(T[] elements) { Preconditions.checkNotNull(elements); return ofInternal(elements.clone()); }
/** * Creates an immutable list that consists of the elements in the given array. A copy of the given array is used which means * that any modifications to the given array will not affect the immutable list. * * @param elements the given array of elements * @return an immutable list */ public static <T> List<T> copyOf(T[] elements) { Preconditions.checkNotNull(elements); return ofInternal(elements.clone()); }
private static void checkInterceptorBinding(Annotation qualifier, MetaAnnotationStore store) { Preconditions.checkNotNull(qualifier); InterceptorBindingModel<?> model = store.getInterceptorBindingModel(qualifier.annotationType()); if (model == null || !model.isValid()) { throw BeanManagerLogger.LOG.interceptorResolutionWithNonbindingType(qualifier); } } }
@Override public boolean add(Class<?> element) { checkNotNull(element); List<Item> list = getDelegate(); synchronized (list) { if (getExtension() != null) { BootstrapLogger.LOG.typeModifiedInAfterTypeDiscovery(getExtension(), element, ADD_OPERATION, getViewType()); } return list.add(createSource(element, list.isEmpty() ? null : list.get(list.size() - 1), null)); } }
@Override public boolean add(Class<?> element) { checkNotNull(element); List<Item> list = getDelegate(); synchronized (list) { if (getExtension() != null) { BootstrapLogger.LOG.typeModifiedInAfterTypeDiscovery(getExtension(), element, ADD_OPERATION, getViewType()); } return list.add(createSource(element, list.isEmpty() ? null : list.get(list.size() - 1), null)); } }
/** * Creates an immutable map. A copy of the given map is used. As a result, it is safe to modify the source map afterwards. * * @param map the given map * @return an immutable map */ public static <K, V> Map<K, V> copyOf(Map<K, V> map) { Preconditions.checkNotNull(map); return ImmutableMap.<K, V> builder().putAll(map).build(); }
public static <T> List<T> copyOf(Iterable<T> source) { Preconditions.checkNotNull(source); if (source instanceof Collection<?>) { return copyOf((Collection<T>) source); } return ImmutableList.<T>builder().addAll(source).build(); }