/** * Gets the value of data that is keyed to the provided {@link Key} at the * give block location. The data may not exist, or may not be compatible in * which case the default value may be returned. * * @param x The X position * @param y The Y position * @param z The Z position * @param key The key to the data * @param defaultValue The default value to return * @param <E> The type of element of data * @return The data or null */ default <E> E getOrElse(int x, int y, int z, Key<? extends BaseValue<E>> key, E defaultValue) { return get(x, y, z, key).orElse(checkNotNull(defaultValue)); }
/** * Gets the value of data that is keyed to the provided {@link Key} at the * give block location. The data may not exist, or may not be compatible in * which case the default value may be returned. * * @param coordinates The position of the block * @param key The key to the data * @param defaultValue The default value to be provided * @param <E> The type of element of data * @return The data or null */ default <E> E getOrElse(Vector3i coordinates, Key<? extends BaseValue<E>> key, E defaultValue) { return get(coordinates.getX(), coordinates.getY(), coordinates.getZ(), key).orElse(checkNotNull(defaultValue)); }
/** * Returns {@code true} if {@code type} is one of the nine * primitive-wrapper types, such as {@link Integer}. * * @see Class#isPrimitive */ public static boolean isWrapperType(Type type) { return WRAPPER_TO_PRIMITIVE_TYPE.containsKey( $Gson$Preconditions.checkNotNull(type)); }
/** * Constructs a Field Attributes object from the {@code f}. * * @param f the field to pull attributes from */ public FieldAttributes(Field f) { $Gson$Preconditions.checkNotNull(f); this.field = f; }
/** * Constructs a Field Attributes object from the {@code f}. * * @param f the field to pull attributes from */ public FieldAttributes(Field f) { $Gson$Preconditions.checkNotNull(f); this.field = f; }
/** * Unsafe. Constructs a type literal manually. */ @SuppressWarnings("unchecked") TypeToken(Type type) { this.type = $Gson$Types.canonicalize($Gson$Preconditions.checkNotNull(type)); this.rawType = (Class<? super T>) $Gson$Types.getRawType(this.type); this.hashCode = this.type.hashCode(); }
/** * Returns {@code true} if {@code type} is one of the nine * primitive-wrapper types, such as {@link Integer}. * * @see Class#isPrimitive */ public static boolean isWrapperType(Type type) { return WRAPPER_TO_PRIMITIVE_TYPE.containsKey( $Gson$Preconditions.checkNotNull(type)); }
/** * Unsafe. Constructs a type literal manually. */ @SuppressWarnings("unchecked") TypeToken(Type type) { this.type = $Gson$Types.canonicalize($Gson$Preconditions.checkNotNull(type)); this.rawType = (Class<? super T>) $Gson$Types.getRawType(this.type); this.hashCode = this.type.hashCode(); }
/** * Returns {@code true} if {@code type} is one of the nine * primitive-wrapper types, such as {@link Integer}. * * @see Class#isPrimitive */ public static boolean isWrapperType(Type type) { return WRAPPER_TO_PRIMITIVE_TYPE.containsKey( $Gson$Preconditions.checkNotNull(type)); }
/** * Constructs a Field Attributes object from the {@code f}. * * @param f the field to pull attributes from */ public FieldAttributes(Field f) { $Gson$Preconditions.checkNotNull(f); this.field = f; }
/** * Returns {@code true} if {@code type} is one of the nine * primitive-wrapper types, such as {@link Integer}. * * @see Class#isPrimitive */ public static boolean isWrapperType(Class<?> type) { return WRAPPER_TO_PRIMITIVE_TYPE.containsKey( $Gson$Preconditions.checkNotNull(type)); }
/** * Returns {@code true} if {@code type} is one of the nine * primitive-wrapper types, such as {@link Integer}. * * @see Class#isPrimitive */ public static boolean isWrapperType(Type type) { return WRAPPER_TO_PRIMITIVE_TYPE.containsKey( $Gson$Preconditions.checkNotNull(type)); }
/** * Constructs a Field Attributes object from the {@code f}. * * @param f the field to pull attributes from */ public FieldAttributes(Field f) { $Gson$Preconditions.checkNotNull(f); this.field = f; }
/** * Returns {@code true} if {@code type} is one of the nine * primitive-wrapper types, such as {@link Integer}. * * @see Class#isPrimitive */ public static boolean isWrapperType(Type type) { return WRAPPER_TO_PRIMITIVE_TYPE.containsKey( $Gson$Preconditions.checkNotNull(type)); }
/** * Returns the corresponding wrapper type of {@code type} if it is a primitive * type; otherwise returns {@code type} itself. Idempotent. * <pre> * wrap(int.class) == Integer.class * wrap(Integer.class) == Integer.class * wrap(String.class) == String.class * </pre> */ public static <T> Class<T> wrap(Class<T> type) { // cast is safe: long.class and Long.class are both of type Class<Long> @SuppressWarnings("unchecked") Class<T> wrapped = (Class<T>) PRIMITIVE_TO_WRAPPER_TYPE.get( $Gson$Preconditions.checkNotNull(type)); return (wrapped == null) ? type : wrapped; }
/** * Returns the corresponding primitive type of {@code type} if it is a * wrapper type; otherwise returns {@code type} itself. Idempotent. * <pre> * unwrap(Integer.class) == int.class * unwrap(int.class) == int.class * unwrap(String.class) == String.class * </pre> */ public static <T> Class<T> unwrap(Class<T> type) { // cast is safe: long.class and Long.class are both of type Class<Long> @SuppressWarnings("unchecked") Class<T> unwrapped = (Class<T>) WRAPPER_TO_PRIMITIVE_TYPE.get( $Gson$Preconditions.checkNotNull(type)); return (unwrapped == null) ? type : unwrapped; } }
public ParameterizedTypeImpl(Type ownerType, Type rawType, Type... typeArguments) { // require an owner type if the raw type needs it if (rawType instanceof Class<?>) { Class<?> rawTypeAsClass = (Class<?>) rawType; boolean isStaticOrTopLevelClass = Modifier.isStatic(rawTypeAsClass.getModifiers()) || rawTypeAsClass.getEnclosingClass() == null; checkArgument(ownerType != null || isStaticOrTopLevelClass); } this.ownerType = ownerType == null ? null : canonicalize(ownerType); this.rawType = canonicalize(rawType); this.typeArguments = typeArguments.clone(); for (int t = 0, length = this.typeArguments.length; t < length; t++) { checkNotNull(this.typeArguments[t]); checkNotPrimitive(this.typeArguments[t]); this.typeArguments[t] = canonicalize(this.typeArguments[t]); } }
public WildcardTypeImpl(Type[] upperBounds, Type[] lowerBounds) { checkArgument(lowerBounds.length <= 1); checkArgument(upperBounds.length == 1); if (lowerBounds.length == 1) { checkNotNull(lowerBounds[0]); checkNotPrimitive(lowerBounds[0]); checkArgument(upperBounds[0] == Object.class); this.lowerBound = canonicalize(lowerBounds[0]); this.upperBound = Object.class; } else { checkNotNull(upperBounds[0]); checkNotPrimitive(upperBounds[0]); this.lowerBound = null; this.upperBound = canonicalize(upperBounds[0]); } }
/** * Unsafe. Constructs a type literal manually. */ @SuppressWarnings("unchecked") TypeToken(Type type) { this.type = $Gson$Types.canonicalize($Gson$Preconditions.checkNotNull(type)); this.rawType = (Class<? super T>) $Gson$Types.getRawType(this.type); this.hashCode = this.type.hashCode(); }
/** * Constructs a Field Attributes object from the {@code f}. * * @param f the field to pull attributes from */ public FieldAttributes(Field f) { $Gson$Preconditions.checkNotNull(f); this.field = f; }