本文整理了Java中com.google.inject.matcher.Matcher.matches()
方法的一些代码示例,展示了Matcher.matches()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Matcher.matches()
方法的具体详情如下:
包路径:com.google.inject.matcher.Matcher
类名称:Matcher
方法名:matches
[英]Returns true if this matches t, false otherwise.
[中]如果匹配t,则返回true,否则返回false。
代码示例来源:origin: com.google.inject/guice
@Override
public boolean matches(T t) {
return a.matches(t) || b.matches(t);
}
代码示例来源:origin: com.google.inject/guice
@Override
public boolean matches(T t) {
return !delegate.matches(t);
}
代码示例来源:origin: com.google.inject/guice
@Override
public boolean matches(T t) {
return a.matches(t) && b.matches(t);
}
代码示例来源:origin: com.google.inject/guice
boolean matches(Method method) {
return methodMatcher.matches(method);
}
代码示例来源:origin: com.google.inject/guice
boolean matches(Class<?> clazz) {
return classMatcher.matches(clazz);
}
代码示例来源:origin: com.google.inject/guice
@Override
public boolean matches(Method m) {
return returnType.matches(m.getReturnType());
}
代码示例来源:origin: apache/shiro
public boolean matches(TypeLiteral typeLiteral) {
return classMatcher.matches(typeLiteral.getRawType());
}
};
代码示例来源:origin: com.google.inject/guice
@Override
public boolean matches(TypeLiteral<?> typeLiteral) {
Type type = typeLiteral.getType();
if (!(type instanceof Class)) {
return false;
}
Class<?> clazz = (Class<?>) type;
return typeMatcher.matches(clazz);
}
代码示例来源:origin: com.google.inject/guice
/**
* Creates a new {@link ProvisionListenerStackCallback} with the correct listeners for the key.
*/
private <T> ProvisionListenerStackCallback<T> create(Binding<T> binding) {
List<ProvisionListener> listeners = null;
for (ProvisionListenerBinding provisionBinding : listenerBindings) {
if (provisionBinding.getBindingMatcher().matches(binding)) {
if (listeners == null) {
listeners = Lists.newArrayList();
}
listeners.addAll(provisionBinding.getListeners());
}
}
if (listeners == null || listeners.isEmpty()) {
// Optimization: don't bother constructing the callback if there are
// no listeners.
return ProvisionListenerStackCallback.emptyListener();
}
return new ProvisionListenerStackCallback<T>(binding, listeners);
}
代码示例来源:origin: apache/shiro
public <I> void hear(TypeLiteral<I> type, TypeEncounter<I> encounter) {
if (InitializableInjectionListener.MATCHER.matches(type)) {
encounter.register(this.<I>castListener(new InitializableInjectionListener<Initializable>()));
}
if (DestroyableInjectionListener.MATCHER.matches(type)) {
encounter.register(this.<I>castListener(new DestroyableInjectionListener<Destroyable>(registry)));
}
}
代码示例来源:origin: apache/shiro
@Test
public void testTypeLiteral() throws Exception {
Matcher<Class> classMatcher = createMock(Matcher.class);
expect(classMatcher.matches(MatchingClass.class)).andReturn(true);
expect(classMatcher.matches(NotMatchingClass.class)).andReturn(false);
replay(classMatcher);
Matcher<TypeLiteral> underTest = ShiroMatchers.typeLiteral(classMatcher);
assertTrue(underTest.matches(TypeLiteral.get(MatchingClass.class)));
assertFalse(underTest.matches(TypeLiteral.get(NotMatchingClass.class)));
verify(classMatcher);
}
代码示例来源:origin: apache/shiro
@Test
public void testUnmatchedPackage() throws Exception {
assertFalse(BeanTypeListener.MATCHER.matches(TypeLiteral.get(GuiceEnvironment.class)));
assertFalse(BeanTypeListener.MATCHER.matches(TypeLiteral.get(ShiroWebModule.class)));
assertFalse(BeanTypeListener.MATCHER.matches(TypeLiteral.get(ShiroAopModule.class)));
}
代码示例来源:origin: apache/shiro
@Test
public void testMatchedPackage() throws Exception {
assertTrue(BeanTypeListener.MATCHER.matches(TypeLiteral.get(SecurityUtils.class)));
assertTrue(BeanTypeListener.MATCHER.matches(TypeLiteral.get(DefaultAnnotationResolver.class)));
assertTrue(BeanTypeListener.MATCHER.matches(TypeLiteral.get(BlowfishCipherService.class)));
}
代码示例来源:origin: com.google.inject/guice
@Override
public TypeConverterBinding getConverter(
String stringValue, TypeLiteral<?> type, Errors errors, Object source) {
TypeConverterBinding matchingConverter = null;
for (State s = this; s != State.NONE; s = s.parent()) {
for (TypeConverterBinding converter : s.getConvertersThisLevel()) {
if (converter.getTypeMatcher().matches(type)) {
if (matchingConverter != null) {
errors.ambiguousTypeConversion(stringValue, source, type, matchingConverter, converter);
}
matchingConverter = converter;
}
}
}
return matchingConverter;
}
代码示例来源:origin: apache/shiro
if (element instanceof InterceptorBinding) {
InterceptorBinding binding = (InterceptorBinding) element;
assertTrue(binding.getClassMatcher().matches(getClass()));
Method method = null;
Class<? extends Annotation> theAnnotation = null;
if (binding.getMethodMatcher().matches(protectedMethods.get(annotation))) {
method = protectedMethods.get(annotation);
theAnnotation = annotation;
代码示例来源:origin: com.google.inject/guice
/** Creates a new members injector and attaches both injection listeners and method aspects. */
private <T> MembersInjectorImpl<T> createWithListeners(TypeLiteral<T> type, Errors errors)
throws ErrorsException {
int numErrorsBefore = errors.size();
Set<InjectionPoint> injectionPoints;
try {
injectionPoints = InjectionPoint.forInstanceMethodsAndFields(type);
} catch (ConfigurationException e) {
errors.merge(e.getErrorMessages());
injectionPoints = e.getPartialValue();
}
ImmutableList<SingleMemberInjector> injectors = getInjectors(injectionPoints, errors);
errors.throwIfNewErrors(numErrorsBefore);
EncounterImpl<T> encounter = new EncounterImpl<>(errors, injector.lookups);
Set<TypeListener> alreadySeenListeners = Sets.newHashSet();
for (TypeListenerBinding binding : typeListenerBindings) {
TypeListener typeListener = binding.getListener();
if (!alreadySeenListeners.contains(typeListener) && binding.getTypeMatcher().matches(type)) {
alreadySeenListeners.add(typeListener);
try {
typeListener.hear(type, encounter);
} catch (RuntimeException e) {
errors.errorNotifyingTypeListener(binding, type, e);
}
}
}
encounter.invalidate();
errors.throwIfNewErrors(numErrorsBefore);
return new MembersInjectorImpl<T>(injector, type, encounter, injectors);
}
代码示例来源:origin: com.mycila.guice.extensions/mycila-guice-injection
@Override
public boolean matches(TypeLiteral<?> t) {
return classMatcher.matches(t.getRawType());
}
};
代码示例来源:origin: mycila/guice
@Override
public boolean matches(TypeLiteral<?> t) {
return classMatcher.matches(t.getRawType());
}
};
代码示例来源:origin: mycila/guice
@Override
public boolean matches(TypeLiteral<?> t) {
return classMatcher.matches(t.getRawType());
}
};
代码示例来源:origin: ops4j/peaberry
public synchronized List<MethodInvocation> get(final Matcher<? super Class<?>> type,
final Matcher<? super Method> method) {
List<MethodInvocation> res = new LinkedList<MethodInvocation>();
for (MethodInvocation inv : cache) {
if (type.matches(inv.getThis().getClass()) && method.matches(inv.getMethod())) {
res.add(inv);
}
}
return res;
}
内容来源于网络,如有侵权,请联系作者删除!