private void checkArguments(final MavenSettings settings, final MavenPom pom) throws NullArgumentException { Arguments.checkNotNull("settings", settings); Arguments.checkNotNull("pom", pom); }
/** * Default constructor. * * @param id the identifier of the loader plan. * @param mavenConfig the information from the Maven project configuration. * @throws BlankArgumentException if {@code id} is blank. * @throws NullArgumentException if {@code mavenConfig} is <code>null</code>. */ public LoaderPlan(final String id, final MavenConfig mavenConfig) throws BlankArgumentException, NullArgumentException { Arguments.checkNotBlank("id", id); Arguments.checkNotNull("mavenConfig", mavenConfig); this.id = id; this.mavenConfig = mavenConfig; }
/** * Checks if {@code value} is blank except <code>null</code>. * * @param name the name of the argument of error reporting. Not used if no * exception is thrown. May be <code>null</code>, although not * recommended. * @param value the value of the argument to check to be not blank but may be * <code>null</code>. * @throws BlankExceptNullArgumentException if {@code value} is blank and not * <code>null</code>. */ public static void checkNotBlankExceptNull(final String name, final String value) throws BlankExceptNullArgumentException { checkNotBlankExceptNull(name, value, null); }
/** * Checks if {@code value} is blank. * * @param name the name of the argument of error reporting. Not used if no * exception is thrown. May be <code>null</code>, although not * recommended. * @param value the value of the argument to check to be not blank. * @throws BlankArgumentException if {@code value} is blank. */ public static void checkNotBlank(final String name, final String value) throws BlankArgumentException { checkNotBlank(name, value, null); }
/** * Default constructor. * * @param id the identifier of the job configuration. * @param configXml the Hudson job configuration file as an XML string. * @throws BlankArgumentException if either {@code id} or {@code configXml} is * blank. */ public HudsonJobConfig(final String id, final String configXml) throws BlankArgumentException { Arguments.checkNotBlank("id", id); Arguments.checkNotBlank("configXml", configXml); this.id = id; this.configXml = configXml; }
/** * Checks if {@code value} is <code>null</code>. * * @param name the name of the argument of error reporting. Not used if no * exception is thrown. May be <code>null</code>, although not * recommended. * @param value the value of the argument to check to be not <code>null</code> * . * @throws NullPointerException if {@code value} is <code>null</code>. */ public static void checkNotNull(final String name, final Object value) throws NullPointerException { checkNotNull(name, value, null); }
/** * Adds a configuration name to the loader plan. * * @param configurationName the name to add. * @throws BlankArgumentException if {@code configurationName} is blank. */ public void addConfigurationName(final String configurationName) throws BlankArgumentException { Arguments.checkNotBlank("configurationName", configurationName); configurationNames.add(configurationName); }
/** * Default constructor. * * @param locationManager the location manager to load resources. * @param loaderConfig the loader configuration to control the loading and * creation of Hudson job configuration files. * @throws NullArgumentException if {@code locationManager} or * {@code loaderConfig} is <code>null</code>. */ public HudsonJobConfigLoader(final LocationManager locationManager, final HudsonJobConfigurationLoaderConfig loaderConfig) throws NullArgumentException { Arguments.checkNotNull("locationManager", locationManager); Arguments.checkNotNull("loaderConfig", loaderConfig); this.locationManager = locationManager; this.loaderConfig = loaderConfig; }
throws BlankArgumentException, IllegalArgumentException Arguments.checkNotBlank("connectionString", connectionString); if (!connectionString.startsWith("scm:"))
/** * Adds the report ID to the list of IDs to render report references. * * @param reportId the report ID to add. * @throws NullArgumentException if {@code reportId} is <code>null</code>. */ public void addReportId(final ReportId reportId) throws NullArgumentException { Arguments.checkNotNull("reportId", reportId); reportIds.add(reportId); }
private static void checkRootElementsMatch(final Element target, final Element toBeMerged) { Arguments.checkNotNull("target", target); Arguments.checkNotNull("toBeMerged", toBeMerged); final String targetName = target.getName(); final String toBeMergedName = toBeMerged.getName(); if (!targetName.equals(toBeMergedName)) { throw new IllegalArgumentException( "The root element names of the XML subtrees to be merged do not" + " match. Target is '" + targetName + "' and toBeMerged is '" + toBeMergedName + "'."); } }
private static void checkArguments(final LoaderPlan plan) throws IllegalArgumentException, NullArgumentException { Arguments.checkNotNull("plan", plan); if (plan.isEmpty()) { throw new IllegalArgumentException("The loader plan must not be empty."); } }
/** * Merges the distinct information from the two documents. * <p> * Note that not the contents of the element is checked to determine if the * contents are equal. The merging algorithm simply checks the element names * and assumes that two elements are the same, if they have the same name and * are on the same level. * </p> * * @param target the document to add information, if missing. * @param toBeMerged the information to add to the {@code target}, if missing. * @throws NullArgumentException if either {@code target} or * {@code toBeMerged} is <code>null</code>. * @throws JDOMException on any problem encountered while merging. */ public static void merge(final Document target, final Document toBeMerged) throws NullArgumentException, JDOMException { Arguments.checkNotNull("target", target); Arguments.checkNotNull("toBeMerged", toBeMerged); merge(target.getRootElement(), toBeMerged.getRootElement()); }
/** * Calculates the XPath for the given {@code element}. * * @param rootElement the root element to the element whose path is to be * calculated. The returned XPath is relative to the element. May be * <code>null</code> if a path from the document root is requested. * @param element the element relative to the {@code rootElement}. * @return the XPath relative to {@code rootElement} to the {@code element}. */ public static String calcXPath(final Element rootElement, final Element element) { Arguments.checkNotNull("element", element); final StringBuilder buffer = new StringBuilder(32); buffer.append(element.getName()); Element current = element; while ((current = current.getParentElement()) != rootElement) // NOPMD { buffer.insert(0, '/').insert(0, current.getName()); } if (rootElement == null) { buffer.insert(0, '/'); } return buffer.toString(); }
/** * Loads loader plans read from the given stream. * * @param inputSource contains an <code>ci-config</code> XML document with * loader information. * @return the loader information from the stream. May be empty, if no loader * information has been found, but is never <code>null</code>. * @throws NullArgumentException if {@code inputSource} is <code>null</code>. */ public List<LoaderPlan> load(final InputSource inputSource) throws NullArgumentException { Arguments.checkNotNull("inputSource", inputSource); final List<LoaderPlan> loaderPlans = new ArrayList<LoaderPlan>(); final SAXBuilder builder = new SAXBuilder(); try { final Document ciConfigXml = builder.build(inputSource); load(loaderPlans, ciConfigXml); } catch (final Exception e) { throw new IllegalArgumentException("Cannot load loader plan from '" + inputSource.getSystemId() + "'.", e); } return loaderPlans; }
Arguments.checkNotNull("reportId", reportId);