本文整理汇总了Java中com.github.ruediste.c3java.linearization.JavaC3类的典型用法代码示例。如果您正苦于以下问题:Java JavaC3类的具体用法?Java JavaC3怎么用?Java JavaC3使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JavaC3类属于com.github.ruediste.c3java.linearization包,在下文中一共展示了JavaC3类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calculatePropertyInfoMap
import com.github.ruediste.c3java.linearization.JavaC3; //导入依赖的package包/类
private static Map<String, PropertyInfo> calculatePropertyInfoMap(Class<?> type) {
Map<String, PropertyInfo> result = new HashMap<>();
try {
for (Class<?> cls : JavaC3.allSuperclassesReverse(type)) {
if (Object.class.equals(cls))
continue;
for (PropertyDeclaration decl : getPropertyDeclarations(cls).values()) {
PropertyInfo existingInfo = result.get(decl.getName());
if (existingInfo == null) {
result.put(decl.getName(), decl.toInfo(type));
} else {
result.put(decl.getName(), existingInfo.extendedWith(decl));
}
}
}
return result;
} catch (Throwable t) {
throw new RuntimeException("Error while creating property info map for " + type, t);
}
}
示例2: getDeclarations
import com.github.ruediste.c3java.linearization.JavaC3; //导入依赖的package包/类
/**
* Get all method declarations which are overridded by a given method
* declaration. The result starts with the given method.
*/
public static Iterable<Method> getDeclarations(Method method) {
ArrayList<Method> result = new ArrayList<>();
result.add(method);
for (Class<?> cls : Iterables.skip(JavaC3.allSuperclasses(method.getDeclaringClass()), 1)) {
for (Method m : cls.getDeclaredMethods()) {
if (m.getName().equals(method.getName())
&& Arrays.equals(m.getParameterTypes(), method.getParameterTypes())) {
if (doesOverride(method, m))
result.add(m);
}
}
}
return result;
}
示例3: orderMembers
import com.github.ruediste.c3java.linearization.JavaC3; //导入依赖的package包/类
/**
* Order members which are all declared in the same class by their
* appearance in the class file (which should match source code order)
*/
public <T extends Member> List<T> orderMembers(Class<?> leafClass, Collection<T> members) {
// group members by declaring class
Multimap<Class<?>, T> memberMap = MultimapBuilder.hashKeys().arrayListValues().build();
for (T member : members) {
memberMap.put(member.getDeclaringClass(), member);
}
return JavaC3.allSuperclassesReverse(leafClass).stream().flatMap(cls -> {
Collection<T> clsMembers = memberMap.get(cls);
if (clsMembers == null)
return Stream.empty();
Map<String, Integer> map = classes.get(Type.getInternalName(cls));
if (map == null)
throw new RuntimeException("type " + cls + " not found in members order index. Did it get scanned?");
return clsMembers.stream().sorted((a, b) -> {
Integer idxA = map.get(memberString(a));
if (idxA == null) {
throw new RuntimeException("Member " + a + " is not declared in " + cls);
}
Integer idxB = map.get(memberString(b));
if (idxB == null) {
throw new RuntimeException("Member " + b + " is not declared in " + cls);
}
return idxA.compareTo(idxB);
});
}).collect(toList());
}
示例4: tryGetTypeLabels
import com.github.ruediste.c3java.linearization.JavaC3; //导入依赖的package包/类
private Optional<Map<String, TypeLabel>> tryGetTypeLabels(Class<?> cls) {
Map<String, TypeLabel> result = getTypeLabelsNoInherit(cls);
if (!result.isEmpty())
return Optional.of(result);
for (Class<?> superClass : Iterables.skip(JavaC3.allSuperclasses(cls), 1)) {
result = getTypeLabelsNoInherit(superClass);
if (!result.isEmpty())
return Optional.of(result);
}
return Optional.empty();
}
示例5: calculatePropertyIntroductionMap
import com.github.ruediste.c3java.linearization.JavaC3; //导入依赖的package包/类
static private Map<String, PropertyDeclaration> calculatePropertyIntroductionMap(Class<?> type) {
Map<String, PropertyDeclaration> result = new HashMap<>();
for (Class<?> cls : Lists.reverse(Lists.newArrayList(JavaC3.allSuperclasses(type)))) {
if (Object.class.equals(cls)) {
continue;
}
for (PropertyDeclaration prop : getPropertyDeclarations(cls).values()) {
result.putIfAbsent(prop.getName(), prop);
}
}
return result;
}