Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Sonatype Nexus (TM) Open Source Version
   * Copyright (c) 2008-2015 Sonatype, Inc.
   * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions.
   *
   * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0,
   * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html.
   *
   * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks
  * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
  * Eclipse Foundation. All other trademarks are the property of their respective owners.
  */
 package org.sonatype.nexus.plugins.capabilities.support.validator;
 
 import  javax.inject.Inject;
 import  javax.inject.Named;
 import  javax.inject.Singleton;
 
 
 import static com.google.common.base.Preconditions.checkNotNull;

Factory of Validators related to capabilities.

Since:
capabilities 2.0
 
 @Named
 @Singleton
 public class CapabilityValidators
 {
 
   private final ValidatorFactory validatorFactory;
 
   @Inject
   public CapabilityValidators(final ValidatorFactory validatorFactory) {
     this. = checkNotNull(validatorFactory);
   }

  
Creates a new validator that is always valid.

Returns:
created validator
 
   public Validator alwaysValid() {
     return .alwaysValid();
   }

  
Creates a new validator that checks that only one capability of specified type and set of properties can be created.

Parameters:
type capability type
propertyKeys optional keys to be included in unique check
Returns:
created validator
 
   public Validator uniquePer(final CapabilityType type,
                              final String... propertyKeys)
   {
     return .uniquePer(typepropertyKeys);
   }

  
Creates a new validator that checks that only one capability of specified type and set of properties can be created, excluding specified capability (by id).

Parameters:
excludeId id of capability to be excluded from unique check
type capability type
propertyKeys optional keys to be included in unique check
Returns:
created validator
 
   public Validator uniquePerExcluding(final CapabilityIdentity excludeId,
                                       final CapabilityType type,
                                       final String... propertyKeys)
   {
     return .uniquePerExcluding(excludeIdtypepropertyKeys);
   }

  
Creates a new validator that checks that a specified property (by key) is present (not null or empty).

Parameters:
type capability type
propertyKey key of required property
Returns:
created validator
 
   public Validator required(final CapabilityType type,
                             final String propertyKey)
   {
     return .required(typepropertyKey);
   }

  
Creates a new validator that checks that a specified property (by key) matches a regexp expression.

Parameters:
type capability type
propertyKey key of property to be matching
regexp to match
Returns:
created validator
  public Validator matches(final CapabilityType type,
                           final String propertyKey,
                           final String regexp)
  {
    return .matches(typepropertyKeyregexp);
  }

  
Creates a new validator that checks constraints expressed by descriptor fields are satisfied.

Parameters:
type capability type
Returns:
created validator
  public Validator constraintsOf(final CapabilityType type) {
    return .constraintsOf(type);
  }
New to GrepCode? Check out our FAQ X