/** * Create a typed name object. * * @param name The name. * @param type The type. * @return An object encapsulating the specified name and type. */ @SuppressWarnings("unchecked") @Nonnull public static <T> TypedName<T> create(String name, Class<T> type) { Preconditions.checkNotNull(name, "name"); Preconditions.checkNotNull(type, "type"); if (type.isPrimitive()) { type = (Class<T>) ClassUtils.primitiveToWrapper(type); } TypedName<T> attribute = new TypedName<>(name.intern(), TypeToken.of(type)); return (TypedName<T>) FIELD_CACHE.intern(NAME_EQUIVALENCE.wrap(attribute)).get(); }
/** * Create a typed name object. * * @param name The name. * @param type The type. * @return An object encapsulating the specified name and type. */ @SuppressWarnings("unchecked") @Nonnull public static <T> TypedName<T> create(String name, TypeToken<T> type) { Preconditions.checkNotNull(name, "name"); Preconditions.checkNotNull(type, "type"); if (type.isPrimitive()) { type = TypeToken.of((Class<T>) ClassUtils.primitiveToWrapper(type.getRawType())); } TypedName<T> attribute = new TypedName<>(name.intern(), type); return (TypedName<T>) FIELD_CACHE.intern(NAME_EQUIVALENCE.wrap(attribute)).get(); }
/** * Create a typed name object. * * @param name The name. * @param type The type. * @return An object encapsulating the specified name and type. */ @SuppressWarnings("unchecked") @Nonnull public static <T> TypedName<T> create(String name, Class<T> type) { Preconditions.checkNotNull(name, "name"); Preconditions.checkNotNull(type, "type"); if (type.isPrimitive()) { type = (Class<T>) ClassUtils.primitiveToWrapper(type); } TypedName<T> attribute = new TypedName<>(name.intern(), TypeToken.of(type)); return (TypedName<T>) FIELD_CACHE.intern(NAME_EQUIVALENCE.wrap(attribute)).get(); }
/** * Create a typed name object. * * @param name The name. * @param type The type. * @return An object encapsulating the specified name and type. */ @SuppressWarnings("unchecked") @Nonnull public static <T> TypedName<T> create(String name, TypeToken<T> type) { Preconditions.checkNotNull(name, "name"); Preconditions.checkNotNull(type, "type"); if (type.isPrimitive()) { type = TypeToken.of((Class<T>) ClassUtils.primitiveToWrapper(type.getRawType())); } TypedName<T> attribute = new TypedName<>(name.intern(), type); return (TypedName<T>) FIELD_CACHE.intern(NAME_EQUIVALENCE.wrap(attribute)).get(); }