本文整理汇总了Java中com.google.common.base.Equivalence.Wrapper类的典型用法代码示例。如果您正苦于以下问题:Java Wrapper类的具体用法?Java Wrapper怎么用?Java Wrapper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Wrapper类属于com.google.common.base.Equivalence包,在下文中一共展示了Wrapper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: selectProperties
import com.google.common.base.Equivalence.Wrapper; //导入依赖的package包/类
private Iterable<ModelPropertyExtractionContext> selectProperties(final ModelSchemaExtractionContext<?> context, CandidateMethods candidateMethods) {
Map<String, ModelPropertyExtractionContext> propertiesMap = Maps.newTreeMap();
for (Map.Entry<Wrapper<Method>, Collection<Method>> entry : candidateMethods.allMethods().entrySet()) {
Method method = entry.getKey().get();
PropertyAccessorType propertyAccessorType = PropertyAccessorType.of(method);
Collection<Method> methodsWithEqualSignature = entry.getValue();
if (propertyAccessorType != null) {
String propertyName = propertyAccessorType.propertyNameFor(method);
ModelPropertyExtractionContext propertyContext = propertiesMap.get(propertyName);
if (propertyContext == null) {
propertyContext = new ModelPropertyExtractionContext(propertyName);
propertiesMap.put(propertyName, propertyContext);
}
propertyContext.addAccessor(new PropertyAccessorExtractionContext(propertyAccessorType, methodsWithEqualSignature));
}
}
return Collections2.filter(propertiesMap.values(), new Predicate<ModelPropertyExtractionContext>() {
@Override
public boolean apply(ModelPropertyExtractionContext property) {
return property.isReadable();
}
});
}
示例2: transitionMethodsForInstantiatedClass
import com.google.common.base.Equivalence.Wrapper; //导入依赖的package包/类
/**
* Marks all methods live that can be reached by calls previously seen.
*
* <p>This should only be invoked if the given type newly becomes instantiated. In essence, this
* method replays all the invokes we have seen so far that could apply to this type and marks
* the corresponding methods live.
*
* <p>Only methods that are visible in this type are considered. That is, only those methods that
* are either defined directly on this type or that are defined on a supertype but are not
* shadowed by another inherited method.
*/
private void transitionMethodsForInstantiatedClass(DexType type) {
Set<Wrapper<DexMethod>> seen = new HashSet<>();
MethodSignatureEquivalence equivalence = MethodSignatureEquivalence.get();
do {
DexClass clazz = appInfo.definitionFor(type);
if (clazz == null) {
reportMissingClass(type);
// TODO(herhut): In essence, our subtyping chain is broken here. Handle that case better.
break;
}
SetWithReason<DexEncodedMethod> reachableMethods = reachableVirtualMethods.get(type);
if (reachableMethods != null) {
for (DexEncodedMethod encodedMethod : reachableMethods.getItems()) {
Wrapper<DexMethod> ignoringClass = equivalence.wrap(encodedMethod.method);
if (!seen.contains(ignoringClass)) {
seen.add(ignoringClass);
markVirtualMethodAsLive(encodedMethod, KeepReason.reachableFromLiveType(type));
}
}
}
type = clazz.superType;
} while (type != null && !instantiatedTypes.contains(type));
}
示例3: markMethod
import com.google.common.base.Equivalence.Wrapper; //导入依赖的package包/类
private void markMethod(DexEncodedMethod method, Collection<ProguardMemberRule> rules,
ProguardConfigurationRule context, Set<Wrapper<DexMethod>> methodsMarked,
DexType onlyIfClassKept) {
if ((methodsMarked != null)
&& methodsMarked.contains(MethodSignatureEquivalence.get().wrap(method.method))) {
return;
}
for (ProguardMemberRule rule : rules) {
if (rule.matches(method, this)) {
if (Log.ENABLED) {
Log.verbose(getClass(), "Marking method `%s` due to `%s { %s }`.", method, context,
rule);
}
if (methodsMarked != null) {
methodsMarked.add(MethodSignatureEquivalence.get().wrap(method.method));
}
addItemToSets(method, context, rule, onlyIfClassKept);
}
}
}
示例4: addNonShadowed
import com.google.common.base.Equivalence.Wrapper; //导入依赖的package包/类
private <T extends PresortedComparable<T>, S extends KeyedDexItem<T>> void addNonShadowed(
Iterator<S> items,
HashMap<Wrapper<T>, S> map,
Equivalence<T> equivalence,
Set<Wrapper<T>> existing,
BiFunction<S, S, S> onConflict) {
while (items.hasNext()) {
S item = items.next();
if (item == null) {
// This item was filtered out by a preprocessing.
continue;
}
Wrapper<T> wrapped = equivalence.wrap(item.getKey());
if (existing.contains(wrapped)) {
S resolved = onConflict.apply(map.get(wrapped), item);
wrapped = equivalence.wrap(resolved.getKey());
map.put(wrapped, resolved);
} else {
map.put(wrapped, item);
}
}
}
示例5: mergePredecessors
import com.google.common.base.Equivalence.Wrapper; //导入依赖的package包/类
static Set<Equivalence.Wrapper<ExprNode>> mergePredecessors(
Map<Block, Set<Equivalence.Wrapper<ExprNode>>> blockToAccessedExprs, Block current) {
Set<Equivalence.Wrapper<ExprNode>> currentBlockSet = null;
for (Block predecessor : current.predecessors) {
Set<Wrapper<ExprNode>> predecessorBlockSet = blockToAccessedExprs.get(predecessor);
if (currentBlockSet == null) {
currentBlockSet = new HashSet<>(predecessorBlockSet);
} else {
currentBlockSet.retainAll(predecessorBlockSet);
}
}
if (currentBlockSet == null) {
currentBlockSet = new HashSet<>();
}
return currentBlockSet;
}
示例6: addTypeSubstitutions
import com.google.common.base.Equivalence.Wrapper; //导入依赖的package包/类
private void addTypeSubstitutions(Map<Wrapper<ExprNode>, SoyType> substitutionsToAdd) {
for (Map.Entry<Wrapper<ExprNode>, SoyType> entry : substitutionsToAdd.entrySet()) {
ExprNode expr = entry.getKey().get();
// Get the existing type
SoyType previousType = expr.getType();
for (TypeSubstitution subst = substitutions; subst != null; subst = subst.parent) {
if (ExprEquivalence.get().equivalent(subst.expression, expr)) {
previousType = subst.type;
break;
}
}
// If the new type is different than the current type, then add a new type substitution.
if (!entry.getValue().equals(previousType)) {
substitutions = new TypeSubstitution(substitutions, expr, entry.getValue());
}
}
}
示例7: computeConstraintIntersection
import com.google.common.base.Equivalence.Wrapper; //导入依赖的package包/类
/**
* Compute a map which combines the constraints from both the left and right side of an
* expression. The result should be a set of constraints which satisfy <strong>either</strong>
* sides.
*
* @param left Constraints from the left side.
* @param right Constraints from the right side.
* @return The combined constraint.
*/
private Map<Wrapper<ExprNode>, SoyType> computeConstraintIntersection(
Map<Wrapper<ExprNode>, SoyType> left, Map<Wrapper<ExprNode>, SoyType> right) {
if (left.isEmpty()) {
return left;
}
if (right.isEmpty()) {
return right;
}
Map<Wrapper<ExprNode>, SoyType> result = Maps.newHashMapWithExpectedSize(left.size());
for (Map.Entry<Wrapper<ExprNode>, SoyType> entry : left.entrySet()) {
// A variable must be present in both the left and right sides in order to be
// included in the output.
if (right.containsKey(entry.getKey())) {
// The intersection of two constraints is a *looser* constraint.
// Thus "((a instanceof any) OR (a instanceof bool)) == (a instanceof any)"
SoyType rightSideType = right.get(entry.getKey());
result.put(
entry.getKey(),
SoyTypes.computeLowestCommonType(typeRegistry, entry.getValue(), rightSideType));
}
}
return result;
}
示例8: assertEquivalent
import com.google.common.base.Equivalence.Wrapper; //导入依赖的package包/类
private void assertEquivalent(ExprNode left, ExprNode right) {
Wrapper<ExprNode> wrappedLeft = ExprEquivalence.get().wrap(left);
Wrapper<ExprNode> wrappedRight = ExprEquivalence.get().wrap(right);
assertThat(wrappedLeft).isEqualTo(wrappedRight);
// Test symmetry
assertThat(wrappedRight).isEqualTo(wrappedLeft);
assertThat(wrappedLeft.hashCode()).isEqualTo(wrappedRight.hashCode());
// If two expressions are equal, then all subexpressions must also be equal
if (left instanceof ParentExprNode) {
List<ExprNode> leftChildren = ((ParentExprNode) left).getChildren();
List<ExprNode> rightChildren = ((ParentExprNode) right).getChildren();
for (int i = 0; i < leftChildren.size(); i++) {
assertEquivalent(leftChildren.get(i), rightChildren.get(i));
}
}
}
示例9: collectPublicViewImplMethods
import com.google.common.base.Equivalence.Wrapper; //导入依赖的package包/类
private static <T> Map<Wrapper<Method>, WeaklyTypeReferencingMethod<?, ?>> collectPublicViewImplMethods(StructSchema<T> publicSchema) {
return indexBySignature(
Sets.filter(
publicSchema.getAllMethods(),
new Predicate<WeaklyTypeReferencingMethod<?, ?>>() {
@Override
public boolean apply(WeaklyTypeReferencingMethod<?, ?> weakMethod) {
return !Modifier.isAbstract(weakMethod.getModifiers());
}
}
)
);
}
示例10: indexBySignature
import com.google.common.base.Equivalence.Wrapper; //导入依赖的package包/类
private static ImmutableMap<Wrapper<Method>, WeaklyTypeReferencingMethod<?, ?>> indexBySignature(Iterable<WeaklyTypeReferencingMethod<?, ?>> methods) {
return Maps.uniqueIndex(methods, new Function<WeaklyTypeReferencingMethod<?, ?>, Wrapper<Method>>() {
@Override
public Wrapper<Method> apply(WeaklyTypeReferencingMethod<?, ?> weakMethod) {
return SIGNATURE_EQUIVALENCE.wrap(weakMethod.getMethod());
}
});
}
示例11: collectImplementedMethods
import com.google.common.base.Equivalence.Wrapper; //导入依赖的package包/类
private static Collection<WeaklyTypeReferencingMethod<?, ?>> collectImplementedMethods(Iterable<StructSchema<?>> implementedSchemas) {
Map<Wrapper<Method>, WeaklyTypeReferencingMethod<?, ?>> implementedMethodsBuilder = Maps.newLinkedHashMap();
for (StructSchema<?> implementedSchema : implementedSchemas) {
for (WeaklyTypeReferencingMethod<?, ?> viewMethod : implementedSchema.getAllMethods()) {
implementedMethodsBuilder.put(DESCRIPTOR_EQUIVALENCE.wrap(viewMethod.getMethod()), viewMethod);
}
}
return implementedMethodsBuilder.values();
}
示例12: computeMethodsOnMessageType
import com.google.common.base.Equivalence.Wrapper; //导入依赖的package包/类
private Set<Wrapper<DexMethod>> computeMethodsOnMessageType() {
DexClass messageClass = appInfo.definitionFor(messageType);
if (messageClass == null) {
return Collections.emptySet();
}
Set<Wrapper<DexMethod>> superMethods = new HashSet<>();
messageClass.forEachMethod(method -> superMethods.add(equivalence.wrap(method.method)));
return superMethods;
}
示例13: markMatchingVisibleMethods
import com.google.common.base.Equivalence.Wrapper; //导入依赖的package包/类
private void markMatchingVisibleMethods(DexClass clazz,
Collection<ProguardMemberRule> memberKeepRules, ProguardConfigurationRule rule,
DexType onlyIfClassKept) {
Set<Wrapper<DexMethod>> methodsMarked = new HashSet<>();
Arrays.stream(clazz.directMethods()).forEach(method ->
markMethod(method, memberKeepRules, rule, methodsMarked, onlyIfClassKept));
while (clazz != null) {
Arrays.stream(clazz.virtualMethods()).forEach(method ->
markMethod(method, memberKeepRules, rule, methodsMarked, onlyIfClassKept));
clazz = application.definitionFor(clazz.superType);
}
}
示例14: addProgramMethods
import com.google.common.base.Equivalence.Wrapper; //导入依赖的package包/类
private void addProgramMethods(Set<Wrapper<DexMethod>> set, DexMethod method,
Equivalence<DexMethod> equivalence) {
DexClass definition = appInfo.definitionFor(method.holder);
if (definition != null && definition.isProgramClass()) {
set.add(equivalence.wrap(method));
}
}
示例15: getInvokes
import com.google.common.base.Equivalence.Wrapper; //导入依赖的package包/类
private Collection<DexMethod> getInvokes() {
if (invokes == null) {
// Collect all reachable methods that are not within a library class. Those defined on
// library classes are known not to have program classes in their signature.
// Also filter methods that only use types from library classes in their signatures. We
// know that those won't conflict.
Set<Wrapper<DexMethod>> filteredInvokes = new HashSet<>();
Equivalence<DexMethod> equivalence = MethodSignatureEquivalence.get();
appInfo.targetedMethods.forEach(m -> addProgramMethods(filteredInvokes, m, equivalence));
invokes = filteredInvokes.stream().map(Wrapper::get).filter(this::removeNonProgram)
.collect(Collectors.toList());
}
return invokes;
}