private static void toJarArchiveComparatorClassPath(Optional<String> classPathOptional, List<String> comparatorClassPath) { if (classPathOptional.isPresent()) { String classPathAsString = classPathOptional.get(); Collections.addAll(comparatorClassPath, classPathAsString.split(File.pathSeparator)); } }
@XmlAttribute public String getTitle() { String title; if (this.titleOptional.isPresent()) { title = this.titleOptional.get(); } else { title = "JApiCmp-Report"; } return title; }
public static <T> String optionalToString(Optional<T> optional) { if (optional.isPresent()) { return optional.get().toString(); } return N_A; } }
public boolean hasChangedTo(T value) { boolean hasChangedTo = false; if (newModifier.isPresent()) { T newValue = newModifier.get(); if (value == newValue) { hasChangedTo = true; } } return hasChangedTo; } }
private String guessVersion(File file) { String name = file.getName(); Optional<SemanticVersion> semanticVersion = japicmp.versioning.Version.getSemanticVersion(name); String version = semanticVersion.isPresent() ? semanticVersion.get().toString() : "n.a."; if (name.contains("SNAPSHOT")) { version += "-SNAPSHOT"; } return version; }
public static String toString(Optional<CtMethod> method) { if(method == null ) { return OptionalHelper.N_A; } if(method.isPresent()) { return method.get().getLongName(); } return OptionalHelper.N_A; }
private JApiJavaObjectSerializationCompatibility.JApiJavaObjectSerializationChangeStatus checkChangesForClassType(JApiClass jApiClass, JApiJavaObjectSerializationCompatibility.JApiJavaObjectSerializationChangeStatus state) { JApiClassType classType = jApiClass.getClassType(); if (classType.getChangeStatus() == JApiChangeStatus.MODIFIED) { JApiClassType.ClassType oldClassType = classType.getOldTypeOptional().get(); JApiClassType.ClassType newClassType = classType.getNewTypeOptional().get(); if (oldClassType != newClassType) { state = JApiJavaObjectSerializationCompatibility.JApiJavaObjectSerializationChangeStatus.SERIALIZABLE_INCOMPATIBLE_CLASS_TYPE_MODIFIED; } } return state; }
@Override public JApiSuperclass callback(JApiClass clazz, Map<String, JApiClass> classMap, JApiChangeStatus changeStatusOfSuperclass) { JApiSuperclass ancestor = clazz.getSuperclass(); if (ancestor.getNewSuperclassName().isPresent() && ancestor.getNewSuperclassName().get().equals(superclass.getOldSuperclassName().get())) { matchingAncestors.add(ancestor); } return ancestor; } });
private void buildInterfaceMap(JarArchiveComparator.ArchiveType archiveType, Map<String, CtClass> map, CtClass ctInterface) throws NotFoundException { Optional<CtClass> loadedInterfaceOptional = this.jarArchiveComparator.loadClass(archiveType, ctInterface.getName()); if (loadedInterfaceOptional.isPresent()) { CtClass loadedInterface = loadedInterfaceOptional.get(); CtClass[] loadedInterfaceInterfaces = loadedInterface.getInterfaces(); for (CtClass additionalInterface : loadedInterfaceInterfaces) { map.put(additionalInterface.getName(), additionalInterface); buildInterfaceMap(archiveType, map, additionalInterface); } } }
private void buildInterfaceMap(JarArchiveComparator.ArchiveType archiveType, Map<String, CtClass> map, CtClass ctInterface) throws NotFoundException { Optional<CtClass> loadedInterfaceOptional = this.jarArchiveComparator.loadClass(archiveType, ctInterface.getName()); if (loadedInterfaceOptional.isPresent()) { CtClass loadedInterface = loadedInterfaceOptional.get(); CtClass[] loadedInterfaceInterfaces = loadedInterface.getInterfaces(); for (CtClass additionalInterface : loadedInterfaceInterfaces) { map.put(additionalInterface.getName(), additionalInterface); buildInterfaceMap(archiveType, map, additionalInterface); } } }
private boolean fieldTypeMatches(JApiField field1, JApiField field2) { boolean matches = true; JApiType type1 = field1.getType(); JApiType type2 = field2.getType(); if (type1.getNewTypeOptional().isPresent() && type2.getNewTypeOptional().isPresent()) { if (!type1.getNewTypeOptional().get().equals(type2.getNewTypeOptional().get())) { matches = false; } } return matches; }
private boolean fieldTypeMatches(JApiField field1, JApiField field2) { boolean matches = true; JApiType type1 = field1.getType(); JApiType type2 = field2.getType(); if (type1.getNewTypeOptional().isPresent() && type2.getNewTypeOptional().isPresent()) { if (!type1.getNewTypeOptional().get().equals(type2.getNewTypeOptional().get())) { matches = false; } } return matches; }
private String superclassChangeAsString(JApiSuperclass jApiSuperclass) { if (jApiSuperclass.getOldSuperclassName().isPresent() && jApiSuperclass.getNewSuperclassName().isPresent()) { return jApiSuperclass.getNewSuperclassName().get() + " (<- " + jApiSuperclass.getOldSuperclassName().get() + ")"; } else if (jApiSuperclass.getOldSuperclassName().isPresent() && !jApiSuperclass.getNewSuperclassName().isPresent()) { return jApiSuperclass.getOldSuperclassName().get(); } else if (!jApiSuperclass.getOldSuperclassName().isPresent() && jApiSuperclass.getNewSuperclassName().isPresent()) { return jApiSuperclass.getNewSuperclassName().get(); } return "n.a."; }
private String superclassChangeAsString(JApiSuperclass jApiSuperclass) { if (jApiSuperclass.getOldSuperclassName().isPresent() && jApiSuperclass.getNewSuperclassName().isPresent()) { return jApiSuperclass.getNewSuperclassName().get() + " (<- " + jApiSuperclass.getOldSuperclassName().get() + ")"; } else if (jApiSuperclass.getOldSuperclassName().isPresent() && !jApiSuperclass.getNewSuperclassName().isPresent()) { return jApiSuperclass.getOldSuperclassName().get(); } else if (!jApiSuperclass.getOldSuperclassName().isPresent() && jApiSuperclass.getNewSuperclassName().isPresent()) { return jApiSuperclass.getNewSuperclassName().get(); } return "n.a."; }
private void checkIfClassNowCheckedException(JApiClass jApiClass) { JApiSuperclass jApiClassSuperclass = jApiClass.getSuperclass(); if (jApiClassSuperclass.getChangeStatus() == JApiChangeStatus.MODIFIED) { if (jApiClassSuperclass.getNewSuperclassName().isPresent()) { String fqn = jApiClassSuperclass.getNewSuperclassName().get(); if ("java.lang.Exception".equals(fqn)) { addCompatibilityChange(jApiClass, JApiCompatibilityChange.CLASS_NOW_CHECKED_EXCEPTION); } } } }
public static boolean hasModifierLevelDecreased(JApiHasAccessModifier hasAccessModifier) { JApiModifier<AccessModifier> accessModifier = hasAccessModifier.getAccessModifier(); if (accessModifier.getOldModifier().isPresent() && accessModifier.getNewModifier().isPresent()) { AccessModifier oldModifier = accessModifier.getOldModifier().get(); AccessModifier newModifier = accessModifier.getNewModifier().get(); if (newModifier.getLevel() < oldModifier.getLevel()) { return true; } } return false; }