本文整理汇总了Java中com.captainbern.reflection.matcher.Matchers类的典型用法代码示例。如果您正苦于以下问题:Java Matchers类的具体用法?Java Matchers怎么用?Java Matchers使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Matchers类属于com.captainbern.reflection.matcher包,在下文中一共展示了Matchers类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getObjectFor
import com.captainbern.reflection.matcher.Matchers; //导入依赖的package包/类
public static Object getObjectFor(PacketData packetData, final String param) {
if (PACKET_DATA == null)
PACKET_DATA = new Reflection().reflect(PacketData.class);
List<SafeField<?>> fields = PACKET_DATA.getSafeFields(Matchers.withNameRegex(Pattern.compile("(" + param + ")", Pattern.CASE_INSENSITIVE)));
if (fields.isEmpty())
throw new IllegalArgumentException("Parameter: \'" + param + "\' does not appear to be valid!");
return fields.get(0).getAccessor().get(packetData);
}
示例2: getObjectFor
import com.captainbern.reflection.matcher.Matchers; //导入依赖的package包/类
private Object getObjectFor(PacketData packetData, final String param) {
if (PACKET_DATA == null)
PACKET_DATA = new Reflection().reflect(PacketData.class);
List<SafeField<?>> fields = PACKET_DATA.getSafeFields(Matchers.withNameRegex(Pattern.compile("(" + param + ")", Pattern.CASE_INSENSITIVE)));
if (fields.isEmpty())
throw new IllegalArgumentException("Parameter: \'" + param + "\' does not appear to be valid!");
return fields.get(0).getAccessor().get(packetData);
}
示例3: match
import com.captainbern.reflection.matcher.Matchers; //导入依赖的package包/类
protected static <T> List<T> match(final List<T> classes, final Matcher<? super T>... matchers) {
if (classes.isEmpty()) {
return classes;
} else {
List<T> elements = new ArrayList<>();
Matcher<T> combinedMatcher = Matchers.combine(Arrays.asList(matchers));
for(T clazz : classes) {
if(combinedMatcher.matches(clazz)) {
elements.add(clazz);
}
}
return elements;
}
}
示例4: match
import com.captainbern.reflection.matcher.Matchers; //导入依赖的package包/类
public static <T> Set<T> match(final Set<T> classes, final Matcher<? super T>... matchers) {
if(classes.isEmpty()) {
return classes;
} else {
Set<T> elements = new HashSet<>();
Matcher<T> combinedMatcher = Matchers.combine(Arrays.asList(matchers));
for(T clazz : classes) {
if(combinedMatcher.matches(clazz)) {
elements.add(clazz);
}
}
return elements;
}
}