/** * Sets the naming pattern to be used by the new {@code * BasicThreadFactory}. * * @param pattern the naming pattern (must not be <b>null</b>) * @return a reference to this {@code Builder} * @throws NullPointerException if the naming pattern is <b>null</b> */ public Builder namingPattern(final String pattern) { Validate.notNull(pattern, "Naming pattern must not be null!"); namingPattern = pattern; return this; }
Validate.isTrue(cls != null, "The class must not be null"); Validate.isTrue(StringUtils.isNotBlank(fieldName), "The field name must not be blank/empty"); try {
@Test public void testNotBlankNotBlankStringShouldNotThrow() { //given final String string = "abc"; //when Validate.notBlank(string); //then should not throw }
/** * @param pathToTrustStore The path to the trust store. REST Assured will first look in the classpath and if not found it will look for the JKS in the local file-system * @param password The store pass * @return A new SSLConfig instance */ public SSLConfig trustStore(String pathToTrustStore, String password) { Validate.notNull(pathToTrustStore, "Path to trust store on the file system cannot be null"); Validate.notEmpty(password, "Password cannot be empty"); return new SSLConfig(pathToKeyStore, pathToTrustStore, keyStorePassword, password, keyStoreType, trustStoreType, port, keyStore, trustStore, x509HostnameVerifier, sslSocketFactory, true); }
/** * Append {@code types} to {@code buf} with separator {@code sep}. * @param buf destination * @param sep separator * @param types to append * @return {@code buf} * @since 3.2 */ private static <T> StringBuilder appendAllTo(final StringBuilder buf, final String sep, final T... types) { Validate.notEmpty(Validate.noNullElements(types)); if (types.length > 0) { buf.append(toString(types[0])); for (int i = 1; i < types.length; i++) { buf.append(sep).append(toString(types[i])); } } return buf; }
Validate.notNull(delivery, "Delivery cannot be null"); Validate.notNull(delivery.getCountry(), "Delivery.country cannot be null"); Validate.notNull(packages, "packages cannot be null"); Validate.notEmpty(packages, "packages cannot be empty"); if(StringUtils.isBlank(delivery.getPostalCode())) { return null;
if (StringUtils.isEmpty(module.getModuleName())) { moduleStr = ""; if (!service.getModule().equals(StringUtils.EMPTY)) { getProjectOperations().addDependency(service.getModule(), DEPENDENCY_SPRINGLETS_MAIL); getTypeLocationService().getTypeDetails(service); Validate.isTrue(serviceTypeDetails != null, "Cannot locate source for '%s'", service.getFullyQualifiedTypeName()); final String declaredByMetadataId = serviceTypeDetails.getDeclaredByMetadataId(); final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(serviceTypeDetails); .asList(new AnnotationMetadataBuilder(AUTOWIRED)), new JavaSymbolName("mailReceiver"), SpringletsJavaType.SPRINGLETS_MAIL_RECEIVER_SERVICE));
@Override public void createProjection(JavaType entity, JavaType name, String fields, String suffix, String formatExpression, String formatMessage) { Validate.notNull(name, "Use --class to select the name of the Projection."); projectOperations.setModule(projectOperations.getPomFromModuleName(name.getModule())); projectOperations.addDependency(name.getModule(), SPRINGLETS_CONTEXT_DEPENDENCY); projectOperations.addProperty("", SPRINGLETS_VERSION_PROPERTY); fieldsToAdd.put(field.getFieldName().getSymbolName(), field); LogicalPath.getInstance(Path.SRC_MAIN_JAVA, name.getModule())); final ClassOrInterfaceTypeDetailsBuilder projectionBuilder = new ClassOrInterfaceTypeDetailsBuilder(declaredByMetadataId, Modifier.PUBLIC, name, fieldNames.add(new StringAttributeValue(new JavaSymbolName("fields"), field.getFieldName() .getSymbolName())); String[] fieldsFromCommand = StringUtils.split(fields, ","); for (int i = 0; i < fieldsFromCommand.length; i++) { fieldNames if (StringUtils.isNotBlank(formatExpression)) { projectionAnnotation.addStringAttribute("formatExpression", formatExpression); if (StringUtils.isNotBlank(formatMessage)) { projectionAnnotation.addStringAttribute("formatMessage", formatMessage);
public MemberTypeAdditions getMemberTypeAdditions(final String callerMID, final String methodIdentifier, final JavaType targetEntity, final JavaType idType, boolean autowire, final MethodParameter... callerParameters) { Validate.isTrue(StringUtils.isNotBlank(callerMID), "Caller's metadata ID required"); Validate.notBlank(methodIdentifier, "Method identifier required"); Validate.notNull(targetEntity, "Target enitity type required"); Validate.notNull(idType, "Enitity Id type required"); // Look for a repository layer method with this ID and parameter types final List<JavaType> parameterTypes = new PairList<JavaType, JavaSymbolName>(callerParameters).getKeys(); final RepositoryJpaLayerMethod method = RepositoryJpaLayerMethod.valueOf(methodIdentifier, parameterTypes, targetEntity, idType); if (method == null) { return null; } // Look for repositories that support this domain type final Collection<ClassOrInterfaceTypeDetails> repositories = repositoryLocator.getRepositories(targetEntity); if (CollectionUtils.isEmpty(repositories)) { return null; } // Use the first such repository (could refine this later) final ClassOrInterfaceTypeDetails repository = repositories.iterator().next(); // Return the additions the caller needs to make return getMethodAdditions(callerMID, method, repository.getName(), Arrays.asList(callerParameters)); }
Validate.isTrue(isBasicType(typeName), "The RequestHeader annotation only supports [String, int, long, float, double, boolean] on %s.", host); if (StringUtils.isEmpty(name)) name = requestHeader.value(); Validate.isTrue(!StringUtils.isEmpty(name), "The name of param is null on %s.", host); Validate.isTrue(mString.equals(typeName), "CookieValue can only be used with [String] on %s.", host); if (StringUtils.isEmpty(name)) name = cookieValue.value(); Validate.notEmpty(name, "The name of cookie is null on %s.", host); Validate.isTrue(isBasicType(typeName), "The PathVariable annotation only supports [String, int, long, float, double, boolean] on %s.", host); Validate.isTrue(!StringUtils.isEmpty(name), "The name of path is null on %s.", host); Validate.isTrue(isBlurred, "The PathVariable annotation must have a blurred path, for example [/project/{name}]. The " + "error occurred on %s.", host); Validate.isTrue(isBasicType(typeName), "The QueryParam annotation only supports [String, int, long, float, double, " + "boolean] on %s.", host); Validate.isTrue(!StringUtils.isEmpty(name), "The name of param is null on %s.", host);
pathOperations.forEach(operation -> buildOperation(markupDocBuilder, operation, config)); } else if (config.getPathsGroupedBy() == GroupBy.TAGS) { Validate.notEmpty(context.getSwagger().getTags(), "Tags must not be empty, when operations are grouped by tags"); markupDocBuilder.sectionTitleWithAnchorLevel2(WordUtils.capitalize(tagName), tagName + "_resource"); String description = tag.getDescription(); if (StringUtils.isNotBlank(description)) { markupDocBuilder.paragraph(description); Validate.notNull(config.getHeaderPattern(), "Header regex pattern must not be empty when operations are grouped using regex");
@Override public final JavaType getJavaType(final String fileIdentifier) { Validate.notBlank(fileIdentifier, "Compilation unit path required"); Validate.isTrue(new File(fileIdentifier).exists(), "The file doesn't exist"); Validate.isTrue(new File(fileIdentifier).isFile(), "The identifier doesn't represent a file"); try { final File file = new File(fileIdentifier); } catch (final IOException ignored) { if (StringUtils.isBlank(typeContents)) { return null; for (final TypeDeclaration typeDeclaration : compilationUnit.getTypes()) { if (typeName.equals(typeDeclaration.getName())) { return new JavaType(compilationUnit.getPackage().getName().getName() + "." + typeDeclaration.getName());
public List<RelationInfoExtended> getRelationInfoFor(final JpaEntityMetadata entityMetadata, final String path) { Validate.notNull(entityMetadata, "entity metadata is required"); Validate.notBlank(path, "path is required"); List<RelationInfoExtended> infos = new ArrayList<RelationInfoExtended>(); String[] split = StringUtils.split(path, '.'); RelationInfo info = entityMetadata.getRelationInfos().get(split[0]); Validate.notNull(info, "%s.%s not found or not a relation field", entityMetadata.getDestination(), split[0]); ClassOrInterfaceTypeDetails childCid = getTypeLocationService().getTypeDetails(info.childType); JpaEntityMetadata childMetadata = getMetadataService().get(JpaEntityMetadata.createIdentifier(childCid)); infos.add(new RelationInfoExtended(info, entityMetadata, childMetadata)); if (split.length > 1) { infos .addAll(getRelationInfoFor(childMetadata, StringUtils.join(split, '.', 1, split.length))); } return infos; }
Validate.notNull(model, "model must not be null!"); if (model instanceof ModelImpl) { ModelImpl modelImpl = (ModelImpl) model; } else if (modelImpl.getType() == null) return null; else if (isNotBlank(modelImpl.getFormat())) return new BasicType(modelImpl.getType(), modelImpl.getTitle(), modelImpl.getFormat()); else
/** * <p>Converts the String to a char using the first character, throwing * an exception on empty Strings.</p> * * <pre> * CharUtils.toChar("A") = 'A' * CharUtils.toChar("BA") = 'B' * CharUtils.toChar(null) throws IllegalArgumentException * CharUtils.toChar("") throws IllegalArgumentException * </pre> * * @param str the character to convert * @return the char value of the first letter of the String * @throws IllegalArgumentException if the String is empty */ public static char toChar(final String str) { Validate.isTrue(StringUtils.isNotEmpty(str), "The String must not be empty"); return str.charAt(0); }
} else { Validate.notNull(itemController, "ERROR: Can't find ITEM-type controller related to controller '%s'", controllerDetail .getType().getFullyQualifiedTypeName()); Validate.notNull(entity, "ERROR: You should provide a valid entity for controller '%s'", controllerDetail.getType().getFullyQualifiedTypeName()); getTypeLocationService().getTypeDetails(entity); Validate.notNull(entityDetails, "ERROR: Can't load details of %s", entity.getFullyQualifiedTypeName()); getMetadataService().get(JpaEntityMetadata.createIdentifier(entityDetails)); Validate.notNull(entityMetadata, "ERROR: Can't get Jpa Entity metada of %s", entity.getFullyQualifiedTypeName()); getPluralService().getPlural(entityMetadata.getCurrentIndentifierField().getFieldName()); ClassOrInterfaceTypeDetails serviceDetails = getTypeLocationService().getTypeDetails(service); String finderName = serviceFinder.getMethodName().getSymbolName(); if (finders.contains(finderName)) { findersToAdd.put(finderName, serviceFinder);
@Override public String getBasePathForController(ClassOrInterfaceTypeDetails controller) { Validate.notNull(controller, "controller is required"); Validate.notNull(controller.getAnnotation(RooJavaType.ROO_CONTROLLER), "%s must be annotated with @%s", controller.getType(), RooJavaType.ROO_CONTROLLER.getSimpleTypeName()); ControllerAnnotationValues values = new ControllerAnnotationValues(controller); StringBuilder sbuilder = getBasePathStringBuilder(controller, values); // Before continue, check if the controller has a custom @RequestMapping annotation AnnotationMetadata requestMappingAnnotation = controller.getAnnotation(SpringJavaType.REQUEST_MAPPING); if (requestMappingAnnotation != null) { String customPath = ""; if (requestMappingAnnotation.getAttribute("value") != null) { String path = (String) requestMappingAnnotation.getAttribute("value").getValue(); // Only the base path should be returned customPath = path.split("\\{")[0]; if (customPath.endsWith("/")) { customPath = customPath.substring(0, customPath.length() - 1); } } // If some path has been specified and is different of the calculated one, return this one if (StringUtils.isNotEmpty(customPath) && !customPath.equals(sbuilder.toString())) { return customPath; } } return sbuilder.toString(); }
AnnotationMetadata wsEndpointsAnnotation = cid.getAnnotation(ROO_WS_ENDPOINTS); Validate.notNull(currentEndpoints, "ERROR: You must provide a valid endpoint list to be able to register endpoints."); getTypeLocationService().getTypeDetails(endpoint); PhysicalTypeIdentifier.getPath(endpointDetails.getDeclaredByMetadataId())); final SeiImplMetadata endpointMetadata = (SeiImplMetadata) getMetadataService().get(endpointMetadataId); if (profileAttr != null && StringUtils.isNotEmpty(profileAttr.getValue())) { profile = profileAttr.getValue();
@Override public Pair<FieldMetadata, RelationInfo> getFieldChildPartOfCompositionRelation( ClassOrInterfaceTypeDetails entityCdi) { JavaType domainType = entityCdi.getType(); List<Pair<FieldMetadata, RelationInfo>> relations = getFieldChildPartOfRelation(entityCdi); if (relations.isEmpty()) { return null; } JpaEntityMetadata parent; JavaType parentType; RelationInfo info; List<Pair<FieldMetadata, RelationInfo>> compositionRelation = new ArrayList<Pair<FieldMetadata, RelationInfo>>(); for (Pair<FieldMetadata, RelationInfo> field : relations) { if (field.getRight().type == JpaRelationType.COMPOSITION) { compositionRelation.add(field); } } Validate.isTrue(compositionRelation.size() <= 1, "Entity %s has more than one relations of composition as child part: ", domainType, StringUtils.join(getFieldNamesOfRelationList(compositionRelation), ",")); if (compositionRelation.isEmpty()) { return null; } return compositionRelation.get(0); }
public boolean isMavenVersion( String versionRange ) { VersionScheme versionScheme = new GenericVersionScheme(); Validate.notBlank( versionRange, "versionRange can neither be null, empty nor blank" ); VersionConstraint constraint; try { constraint = versionScheme.parseVersionConstraint( versionRange ); } catch ( InvalidVersionSpecificationException e ) { throw new IllegalArgumentException( e.getMessage(), e ); } Version current; try { String mavenVersion = getMavenVersion(); Validate.validState( StringUtils.isNotEmpty( mavenVersion ), "Could not determine current Maven version" ); current = versionScheme.parseVersion( mavenVersion ); } catch ( InvalidVersionSpecificationException e ) { throw new IllegalStateException( "Could not parse current Maven version: " + e.getMessage(), e ); } if ( constraint.getRange() == null ) { return constraint.getVersion().compareTo( current ) <= 0; } return constraint.containsVersion( current ); }