public static Optional<AccessModifier> toModifier(String accessModifierArg) { Optional<String> stringOptional = Optional.fromNullable(accessModifierArg); if (stringOptional.isPresent()) { try { return Optional.of(valueOf(stringOptional.get().toUpperCase())); } catch (IllegalArgumentException e) { throw new JApiCmpException(JApiCmpException.Reason.CliError, String.format("Invalid value for option accessModifier: %s. Possible values are: %s.", accessModifierArg, listOfAccessModifier()), e); } } else { return Optional.of(PROTECTED); } } }
throw new MojoFailureException("Please provide at least one old version."); } else { return Optional.absent(); throw new MojoFailureException("Please provide at least one new version."); } else { return Optional.absent(); for (JApiCmpArchive file : this.oldArchives) { Optional<SemanticVersion> semanticVersion = file.getVersion().getSemanticVersion(); if (semanticVersion.isPresent()) { oldVersions.add(semanticVersion.get()); if (semanticVersion.isPresent()) { newVersions.add(semanticVersion.get()); SemanticVersion newVersion = newVersions.get(i); Optional<SemanticVersion.ChangeType> changeTypeOptional = oldVersion.computeChangeType(newVersion); if (changeTypeOptional.isPresent()) { changeTypes.add(changeTypeOptional.get()); return Optional.fromNullable(maxRank);
private Optional<JApiAnnotation> getTransientAnnotationOfField(JApiField field) { Optional<JApiAnnotation> returnValue = Optional.absent(); for (JApiAnnotation annotation : field.getAnnotations()) { if (JpaAnalyzer.JPA_ANNOTATION_TRANSIENT.equals(annotation.getFullyQualifiedName())) { returnValue = Optional.of(annotation); break; } } return returnValue; }
private Optional<JApiMethod> getPropertyMethod(JApiField field) { Optional<JApiMethod> propertyMethod = Optional.absent(); String fieldName = field.getName(); String getterName = "get" + (Character.isUpperCase(fieldName.charAt(0)) ? fieldName : fieldName.length() > 1 ? Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1) : Character.toUpperCase(fieldName.charAt(0))); for (JApiMethod method : jApiClass.getMethods()) { if (getterName.equals(method.getName())) { propertyMethod = Optional.of(method); break; } } if (!propertyMethod.isPresent()) { String isName = "is" + getterName.substring(3); for (JApiMethod method : jApiClass.getMethods()) { if (isName.equals(method.getName())) { propertyMethod = Optional.of(method); break; } } } return propertyMethod; }
public void setTitle(String title) { this.titleOptional = Optional.fromNullable(title); }
private Optional<CtClass> getSuperclass(CtClass ctClass) { try { CtClass superClass = ctClass.getSuperclass(); return Optional.fromNullable(superClass); } catch (NotFoundException e) { if (options.getIgnoreMissingClasses().ignoreClass(e.getMessage())) { return Optional.absent(); } else { throw JApiCmpException.forClassLoading(e, e.getMessage(), jarArchiveComparator); } } }
public Optional<ChangeType> computeChangeType(SemanticVersion version) { if (this.major != version.major) { return Optional.of(ChangeType.MAJOR); } if (this.minor != version.minor) { return Optional.of(ChangeType.MINOR); } if (this.patch != version.patch) { return Optional.of(ChangeType.PATCH); } return Optional.of(ChangeType.UNCHANGED); }
if (excludes != null) { for (String exclude : excludes) { options.addExcludeFromArgument(Optional.fromNullable(exclude), parameterParam.isExcludeExclusively()); if (includes != null) { for (String include : includes) { options.addIncludeFromArgument(Optional.fromNullable(include), parameterParam.isIncludeExlusively()); options.setHtmlStylesheet(Optional.of(htmlStylesheet));
private void extractAttributes() { List<JApiField> fields = jApiClass.getFields(); for (JApiField field : fields) { Optional<JApiAnnotation> transientAnnotationOfFieldOptional = getTransientAnnotationOfField(field); Optional<JApiAnnotation> transientAnnotationOfPropertyOptional = getTransientAnnotationOfProperty(field); if (!transientAnnotationOfFieldOptional.isPresent() && !transientAnnotationOfPropertyOptional.isPresent()) { JApiChangeStatus fieldChangeStatus = field.getChangeStatus(); if (fieldChangeStatus == JApiChangeStatus.NEW) { JpaAttribute jpaAttribute = new JpaAttribute(JApiChangeStatus.NEW); } } } }
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 int hashCode() { int result = fullyQualifiedName != null ? fullyQualifiedName.hashCode() : 0; result = 31 * result + (type != null ? type.hashCode() : 0); result = 31 * result + (value != null ? value.hashCode() : 0); result = 31 * result + (name != null ? name.hashCode() : 0); return result; }
public List<Filter> createFilterList(Optional<String> argumentString, List<Filter> filters, String errorMessage, boolean exclusive) { for (String filterString : Splitter.on(";").trimResults().omitEmptyStrings().split(argumentString.or(""))) { try { // filter based on annotations if (filterString.startsWith("@")) { filters.add(new AnnotationClassFilter(filterString)); filters.add(new AnnotationFieldFilter(filterString)); filters.add(new AnnotationBehaviorFilter(filterString)); } if (filterString.contains("#")) { if (filterString.contains("(")) { JavadocLikeBehaviorFilter behaviorFilter = new JavadocLikeBehaviorFilter(filterString); filters.add(behaviorFilter); } else { JavadocLikeFieldFilter fieldFilter = new JavadocLikeFieldFilter(filterString); filters.add(fieldFilter); } } else { JavaDocLikeClassFilter classFilter = new JavaDocLikeClassFilter(filterString); filters.add(classFilter); JavadocLikePackageFilter packageFilter = new JavadocLikePackageFilter(filterString, exclusive); filters.add(packageFilter); } } catch (Exception e) { throw new JApiCmpException(JApiCmpException.Reason.CliError, String.format(errorMessage, filterString, e.getMessage()), e); } } return filters; }
"follow the rules for semantic versioning."); } else { return Optional.absent(); "follow the rules for semantic versioning."); } else { return Optional.absent(); SemanticVersion newVersion = newVersions.get(i); Optional<SemanticVersion.ChangeType> changeTypeOptional = oldVersion.computeChangeType(newVersion); if (changeTypeOptional.isPresent()) { changeTypes.add(changeTypeOptional.get()); return Optional.fromNullable(maxRank);
private Optional<JApiAnnotation> getTransientAnnotationOfField(JApiField field) { Optional<JApiAnnotation> returnValue = Optional.absent(); for (JApiAnnotation annotation : field.getAnnotations()) { if (JpaAnalyzer.JPA_ANNOTATION_TRANSIENT.equals(annotation.getFullyQualifiedName())) { returnValue = Optional.of(annotation); break; } } return returnValue; }
private Optional<JApiMethod> getPropertyMethod(JApiField field) { Optional<JApiMethod> propertyMethod = Optional.absent(); String fieldName = field.getName(); String getterName = "get" + (Character.isUpperCase(fieldName.charAt(0)) ? fieldName : fieldName.length() > 1 ? Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1) : Character.toUpperCase(fieldName.charAt(0))); for (JApiMethod method : jApiClass.getMethods()) { if (getterName.equals(method.getName())) { propertyMethod = Optional.of(method); break; } } if (!propertyMethod.isPresent()) { String isName = "is" + getterName.substring(3); for (JApiMethod method : jApiClass.getMethods()) { if (isName.equals(method.getName())) { propertyMethod = Optional.of(method); break; } } } return propertyMethod; }
public void setTitle(String title) { this.title = Optional.fromNullable(title); }
private Optional<CtClass> getSuperclass(CtClass ctClass) { try { CtClass superClass = ctClass.getSuperclass(); return Optional.fromNullable(superClass); } catch (NotFoundException e) { if (options.getIgnoreMissingClasses().ignoreClass(e.getMessage())) { return Optional.absent(); } else { throw JApiCmpException.forClassLoading(e, e.getMessage(), jarArchiveComparator); } } }