本文整理汇总了Java中com.google.inject.internal.MoreTypes类的典型用法代码示例。如果您正苦于以下问题:Java MoreTypes类的具体用法?Java MoreTypes怎么用?Java MoreTypes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MoreTypes类属于com.google.inject.internal包,在下文中一共展示了MoreTypes类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: exposeInternal
import com.google.inject.internal.MoreTypes; //导入依赖的package包/类
private <T> AnnotatedElementBuilder exposeInternal(Key<T> key) {
if (privateElements == null) {
addError(
"Cannot expose %s on a standard binder. "
+ "Exposed bindings are only applicable to private binders.",
key);
return new AnnotatedElementBuilder() {
@Override
public void annotatedWith(Class<? extends Annotation> annotationType) {}
@Override
public void annotatedWith(Annotation annotation) {}
};
}
ExposureBuilder<T> builder =
new ExposureBuilder<T>(this, getElementSource(), MoreTypes.canonicalizeKey(key));
privateElements.addExposureBuilder(builder);
return builder;
}
开发者ID:google,项目名称:guice,代码行数:21,代码来源:Elements.java
示例2: justInTimeResolution
import com.google.inject.internal.MoreTypes; //导入依赖的package包/类
@Override
public boolean justInTimeResolution(Injectee injectee) {
Type type = injectee.getRequiredType();
Class<?> clazz = MoreTypes.getRawType(type);
if (clazz != null) {
Binding<?> binding = findBinding(injectee);
if (binding != null) {
Key<?> key = binding.getKey();
Set<Annotation> qualifiers = BindingUtils.getQualifiers(key);
GuiceBindingDescriptor<?> descriptor = new GuiceBindingDescriptor<>(
type, clazz, qualifiers, binding);
ServiceLocatorUtilities.addOneDescriptor(locator, descriptor);
return true;
}
}
return false;
}
开发者ID:Squarespace,项目名称:jersey2-guice,代码行数:22,代码来源:GuiceJustInTimeResolver.java
示例3: define
import com.google.inject.internal.MoreTypes; //导入依赖的package包/类
/**
* Register a Java type and produces an equivalent RAML type. It returns an existing RAML type if
* the Java type was registered already.
*
* @param type Java type.
* @return RAML type.
*/
public RamlType define(Type type) {
if (types == null) {
types = new LinkedHashMap<>();
}
Type componentType = componentType(type);
String typeName = MoreTypes.getRawType(componentType).getSimpleName();
RamlType ramlType = RamlType.valueOf(typeName);
if (ramlType.isObject()) {
RamlType existing = types.get(typeName);
if (existing == null) {
ModelConverters converter = ModelConverters.getInstance();
Property property = converter.readAsProperty(componentType);
Map<PropertyBuilder.PropertyId, Object> args = new EnumMap<>(
PropertyBuilder.PropertyId.class);
for (Map.Entry<String, Model> entry : converter.readAll(componentType).entrySet()) {
define(entry.getKey(), entry.getValue());
}
ramlType = define(typeName, PropertyBuilder.toModel(PropertyBuilder.merge(property, args)));
} else {
ramlType = existing;
}
}
return type != componentType ? ramlType.toArray() : ramlType;
}
开发者ID:jooby-project,项目名称:jooby,代码行数:34,代码来源:Raml.java
示例4: extractBuilderType
import com.google.inject.internal.MoreTypes; //导入依赖的package包/类
private Type extractBuilderType()
{
Class<?> builderClass = extractBuilderClass();
if (builderClass == null) {
return null;
}
if (builderClass.getTypeParameters().length == 0) {
return builderClass;
}
if (!(structType instanceof ParameterizedType)) {
metadataErrors.addError("Builder class '%s' may only be generic if the type it builds ('%s') is also generic", builderClass.getName(), getStructClass().getName());
return builderClass;
}
if (builderClass.getTypeParameters().length != getStructClass().getTypeParameters().length) {
metadataErrors.addError(
"Generic builder class '%s' must have the same number of type parameters as the type it builds ('%s')",
builderClass.getName(),
getStructClass().getName());
return builderClass;
}
ParameterizedType parameterizedStructType = (ParameterizedType) structType;
return new MoreTypes.ParameterizedTypeImpl(builderClass.getEnclosingClass(), builderClass, parameterizedStructType.getActualTypeArguments());
}
开发者ID:airlift,项目名称:drift,代码行数:30,代码来源:AbstractThriftMetadataBuilder.java
示例5: Key
import com.google.inject.internal.MoreTypes; //导入依赖的package包/类
/**
* Unsafe. Constructs a key from a manually specified type.
*/
@SuppressWarnings("unchecked")
private Key(Type type, AnnotationStrategy annotationStrategy) {
this.annotationStrategy = annotationStrategy;
this.typeLiteral = MoreTypes
.canonicalizeForKey((TypeLiteral<T>) TypeLiteral.get(type));
this.hashCode = computeHashCode();
this.toStringSupplier = createToStringSupplier();
}
开发者ID:ruediste,项目名称:salta,代码行数:12,代码来源:Key.java
示例6: testToString
import com.google.inject.internal.MoreTypes; //导入依赖的package包/类
public void testToString() {
Assert.assertEquals("java.lang.String",
MoreTypes.typeToString(String.class));
assertEquals("java.util.Set<java.lang.String>[][]",
MoreTypes.typeToString(setStringArray));
assertEquals("java.util.Map<java.lang.String, java.lang.Integer>",
MoreTypes.typeToString(mapStringInteger));
assertEquals("java.util.List<java.util.Set<java.lang.String>[][]>",
MoreTypes.typeToString(listSetStringArray));
assertEquals(innerFloatDouble.toString(),
MoreTypes.typeToString(innerFloatDouble));
}
开发者ID:ruediste,项目名称:salta,代码行数:13,代码来源:TypesTest.java
示例7: toString
import com.google.inject.internal.MoreTypes; //导入依赖的package包/类
/**
* Returns the method's declaring type and name in the format used in
* javadoc, e.g. {@code com.bar.Foo#baz(com.bar.Foo, com.bar.Bar)}, with
* resolved type parameters.
*
* @return string representation for this method including the declaring type
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getName()).append("(");
List<String> parameters = new ArrayList<String>();
for (Type parameterType : getRawParameterTypes()) {
// TODO(schmitt): We are not respecting varargs here.
parameters.add(MoreTypes.typeToString(parameterType));
}
sb.append(join(", ", parameters)).append(")");
return String.format("%s#%s", getDeclaringType(), sb.toString());
}
开发者ID:google-code-export,项目名称:google-gin,代码行数:22,代码来源:MethodLiteral.java
示例8: TypeLiteral
import com.google.inject.internal.MoreTypes; //导入依赖的package包/类
/**
* Constructs a new type literal. Derives represented class from type parameter.
*
* <p>Clients create an empty anonymous subclass. Doing so embeds the type parameter in the
* anonymous class's type hierarchy so we can reconstitute it at runtime despite erasure.
*/
@SuppressWarnings("unchecked")
protected TypeLiteral() {
this.type = getSuperclassTypeParameter(getClass());
this.rawType = (Class<? super T>) MoreTypes.getRawType(type);
this.hashCode = type.hashCode();
}
开发者ID:google,项目名称:guice,代码行数:13,代码来源:TypeLiteral.java
示例9: Key
import com.google.inject.internal.MoreTypes; //导入依赖的package包/类
/** Unsafe. Constructs a key from a manually specified type. */
@SuppressWarnings("unchecked")
private Key(Type type, AnnotationStrategy annotationStrategy) {
this.annotationStrategy = annotationStrategy;
this.typeLiteral = MoreTypes.canonicalizeForKey((TypeLiteral<T>) TypeLiteral.get(type));
this.hashCode = computeHashCode();
}
开发者ID:google,项目名称:guice,代码行数:8,代码来源:Key.java
示例10: getMembersInjector
import com.google.inject.internal.MoreTypes; //导入依赖的package包/类
@Override
public <T> MembersInjector<T> getMembersInjector(final TypeLiteral<T> typeLiteral) {
final MembersInjectorLookup<T> element =
new MembersInjectorLookup<T>(
getElementSource(), MoreTypes.canonicalizeForKey(typeLiteral));
elements.add(element);
return element.getMembersInjector();
}
开发者ID:google,项目名称:guice,代码行数:9,代码来源:Elements.java
示例11: testToString
import com.google.inject.internal.MoreTypes; //导入依赖的package包/类
public void testToString() {
Assert.assertEquals("java.lang.String", MoreTypes.typeToString(String.class));
assertEquals("java.util.Set<java.lang.String>[][]", MoreTypes.typeToString(setStringArray));
assertEquals(
"java.util.Map<java.lang.String, java.lang.Integer>",
MoreTypes.typeToString(mapStringInteger));
assertEquals(
"java.util.List<java.util.Set<java.lang.String>[][]>",
MoreTypes.typeToString(listSetStringArray));
assertEquals(innerFloatDouble.toString(), MoreTypes.typeToString(innerFloatDouble));
}
开发者ID:google,项目名称:guice,代码行数:12,代码来源:TypesTest.java
示例12: TypeLiteral
import com.google.inject.internal.MoreTypes; //导入依赖的package包/类
/**
* Unsafe. Constructs a type literal manually.
*/
@SuppressWarnings("unchecked")
TypeLiteral(Type type) {
this.type = canonicalize(checkNotNull(type, "type"));
this.rawType = (Class<? super T>) MoreTypes.getRawType(this.type);
this.hashCode = this.type.hashCode();
}
开发者ID:cgruber,项目名称:guice-old,代码行数:10,代码来源:TypeLiteral.java
示例13: Key
import com.google.inject.internal.MoreTypes; //导入依赖的package包/类
/**
* Unsafe. Constructs a key from a manually specified type.
*/
@SuppressWarnings("unchecked")
private Key(Type type, AnnotationStrategy annotationStrategy) {
this.annotationStrategy = annotationStrategy;
this.typeLiteral = MoreTypes.canonicalizeForKey((TypeLiteral<T>) TypeLiteral.get(type));
this.hashCode = computeHashCode();
this.toStringSupplier = createToStringSupplier();
}
开发者ID:cgruber,项目名称:guice-old,代码行数:11,代码来源:Key.java
示例14: testToString
import com.google.inject.internal.MoreTypes; //导入依赖的package包/类
public void testToString() {
Assert.assertEquals("java.lang.String", MoreTypes.typeToString(String.class));
assertEquals("java.util.Set<java.lang.String>[][]", MoreTypes.typeToString(setStringArray));
assertEquals("java.util.Map<java.lang.String, java.lang.Integer>",
MoreTypes.typeToString(mapStringInteger));
assertEquals("java.util.List<java.util.Set<java.lang.String>[][]>",
MoreTypes.typeToString(listSetStringArray));
assertEquals(innerFloatDouble.toString(),
MoreTypes.typeToString(innerFloatDouble));
}
开发者ID:cgruber,项目名称:guice-old,代码行数:11,代码来源:TypesTest.java
示例15: enums
import com.google.inject.internal.MoreTypes; //导入依赖的package包/类
/**
* List of enum values when the {@link #type()} represents an enum.
*
* @return Enum values.
*/
public List<String> enums() {
return Optional.ofNullable(MoreTypes.getRawType(type))
.map(Class::getEnumConstants)
.filter(Objects::nonNull)
.map(values -> Arrays.asList(values).stream()
.map(value -> ((Enum) value).name())
.collect(Collectors.toList())
).orElse(Collections.emptyList());
}
开发者ID:jooby-project,项目名称:jooby,代码行数:15,代码来源:RouteParameter.java
示例16: componentType
import com.google.inject.internal.MoreTypes; //导入依赖的package包/类
private Type componentType(final Type type) {
Class<?> rawType = MoreTypes.getRawType(type);
if (rawType.isArray()) {
return rawType.getComponentType();
}
if (Collection.class.isAssignableFrom(rawType) && type instanceof ParameterizedType) {
return ((ParameterizedType) type).getActualTypeArguments()[0];
}
return type;
}
开发者ID:jooby-project,项目名称:jooby,代码行数:11,代码来源:Raml.java
示例17: simplifyType
import com.google.inject.internal.MoreTypes; //导入依赖的package包/类
static java.lang.reflect.Type simplifyType(final java.lang.reflect.Type type) {
Class<?> rawType = MoreTypes.getRawType(type);
if (Primitives.isWrapperType(rawType)) {
return Primitives.unwrap(rawType);
}
return type;
}
开发者ID:jooby-project,项目名称:jooby,代码行数:8,代码来源:BytecodeRouteParser.java
示例18: Key
import com.google.inject.internal.MoreTypes; //导入依赖的package包/类
/**
* Unsafe. Constructs a key from a manually specified type.
*/
@SuppressWarnings("unchecked")
private Key(Type type, AnnotationStrategy annotationStrategy) {
this.annotationStrategy = annotationStrategy;
this.typeLiteral = MoreTypes.canonicalizeForKey((TypeLiteral<T>) TypeLiteral.get(type));
this.hashCode = computeHashCode();
}
开发者ID:utopiazh,项目名称:google-guice,代码行数:10,代码来源:Key.java
示例19: equals
import com.google.inject.internal.MoreTypes; //导入依赖的package包/类
@Override
public final boolean equals(Object o) {
return o instanceof TypeLiteral<?> && MoreTypes.equals(type, ((TypeLiteral) o).type);
}
开发者ID:google,项目名称:guice,代码行数:5,代码来源:TypeLiteral.java
示例20: toString
import com.google.inject.internal.MoreTypes; //导入依赖的package包/类
@Override
public final String toString() {
return MoreTypes.typeToString(type);
}
开发者ID:google,项目名称:guice,代码行数:5,代码来源:TypeLiteral.java
注:本文中的com.google.inject.internal.MoreTypes类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论