@Test public void parse() { DependencyAtom atom = DependencyAtom.parse(null, null); assertNull(atom); atom = DependencyAtom.parse("", null); assertNull(atom); AtomicReference<String> error = new AtomicReference<String>(); atom = DependencyAtom.parse("", error); assertNull(atom); assertEquals("missing namespace, name and version", error.get()); error.set(null); atom = DependencyAtom.parse("test", error); assertNull(atom); assertEquals("missing name and version", error.get()); error.set(null); atom = DependencyAtom.parse("test and more", error); assertNull(atom); assertEquals("has spaces which are not allowed in dependency atoms.", error.get()); error.set(null); atom = DependencyAtom.parse(" test ", error); assertNull(atom); assertEquals("missing name and version", error.get()); error.set(null); atom = DependencyAtom.parse("namespace:name", error); assertNull(atom); assertEquals("missing version", error.get()); error.set(null); atom = DependencyAtom.parse("namespace:name:version:artifact-name.zip:nottransient", error); assertNull(atom); assertEquals("transient", error.get()); error.set(null); atom = DependencyAtom.parse("namespace:name:version", error); assertNotNull(atom); assertNull(error.get()); assertEquals("namespace", atom.namespace); assertEquals("name", atom.name); assertEquals("version", atom.version); assertNull(atom.artifactName); assertEquals("version:name-version." + DependencyAtom.DEFAULT_PACKAGING, atom.getResolvedPropertyValue()); assertFalse(atom.transientDep); error.set(null); atom = DependencyAtom.parse("namespace:name:version:", error); assertNotNull(atom); assertNull(error.get()); assertEquals("namespace", atom.namespace); assertEquals("name", atom.name); assertEquals("version", atom.version); assertNull(atom.artifactName); assertEquals("version:name-version." + DependencyAtom.DEFAULT_PACKAGING, atom.getResolvedPropertyValue()); assertFalse(atom.transientDep); error.set(null); atom = DependencyAtom.parse("namespace:name:version:artifact-name.zip", error); assertNotNull(atom); assertNull(error.get()); assertEquals("namespace", atom.namespace); assertEquals("name", atom.name); assertEquals("version", atom.version); assertEquals("artifact-name.zip", atom.artifactName); assertEquals("version:artifact-name.zip", atom.getResolvedPropertyValue()); assertFalse(atom.transientDep); error.set(null); atom = DependencyAtom.parse("namespace:name:version:transient", error); assertNotNull(atom); assertNull(error.get()); assertEquals("namespace", atom.namespace); assertEquals("name", atom.name); assertEquals("version", atom.version); assertNull(atom.artifactName); assertEquals("version:name-version." + DependencyAtom.DEFAULT_PACKAGING + ":transient", atom.getResolvedPropertyValue()); assertTrue(atom.transientDep); error.set(null); atom = DependencyAtom.parse("namespace:name:version:artifact-name.zip:transient", error); assertNotNull(atom); assertNull(error.get()); assertEquals("namespace", atom.namespace); assertEquals("name", atom.name); assertEquals("version", atom.version); assertEquals("artifact-name.zip", atom.artifactName); assertEquals("version:artifact-name.zip:transient", atom.getResolvedPropertyValue()); assertTrue(atom.transientDep); }
public static DependencyAtom parse(String atom, AtomicReference<String> error) { if (atom == null) { return null; } atom = atom.trim(); if (atom.contains(" ")) { if (error != null) { error.set("has spaces which are not allowed in dependency atoms."); } return null; } String[] parsed = atom.split(":"); if ((parsed.length < 3) || (parsed.length > 5)) { if (error != null) { if ((parsed.length == 1) && parsed[0].isEmpty()) { parsed = new String[0]; } switch (parsed.length) { case 0: error.set("missing namespace, name and version"); break; case 1: error.set("missing name and version"); break; default: error.set("missing version"); } } return null; } else if ((parsed.length == 5) && !"transient".equalsIgnoreCase(parsed[4])) { error.set("transient"); return null; } return (parsed.length == 3 ? new DependencyAtom(parsed[0], parsed[1], parsed[2]) : parsed.length == 4 ? ("transient".equalsIgnoreCase(parsed[3])) ? new DependencyAtom(parsed[0], parsed[1], parsed[2], true) : new DependencyAtom(parsed[0], parsed[1], parsed[2], parsed[3]) : new DependencyAtom(parsed[0], parsed[1], parsed[2], parsed[3], "transient".equalsIgnoreCase(parsed[4]))); }
DependencyAtom { public static DependencyAtom parse(String atom, AtomicReference<String> error) { if (atom == null) { return null; } atom = atom.trim(); if (atom.contains(" ")) { if (error != null) { error.set("has spaces which are not allowed in dependency atoms."); } return null; } String[] parsed = atom.split(":"); if ((parsed.length < 3) || (parsed.length > 5)) { if (error != null) { if ((parsed.length == 1) && parsed[0].isEmpty()) { parsed = new String[0]; } switch (parsed.length) { case 0: error.set("missing namespace, name and version"); break; case 1: error.set("missing name and version"); break; default: error.set("missing version"); } } return null; } else if ((parsed.length == 5) && !"transient".equalsIgnoreCase(parsed[4])) { error.set("transient"); return null; } return (parsed.length == 3 ? new DependencyAtom(parsed[0], parsed[1], parsed[2]) : parsed.length == 4 ? ("transient".equalsIgnoreCase(parsed[3])) ? new DependencyAtom(parsed[0], parsed[1], parsed[2], true) : new DependencyAtom(parsed[0], parsed[1], parsed[2], parsed[3]) : new DependencyAtom(parsed[0], parsed[1], parsed[2], parsed[3], "transient".equalsIgnoreCase(parsed[4]))); } }
DependencyAtom { public static DependencyAtom parse(String atom, AtomicReference<String> error) { if (atom == null) { return null; } atom = atom.trim(); if (atom.contains(" ")) { if (error != null) { error.set("has spaces which are not allowed in dependency atoms."); } return null; } String[] parsed = atom.split(":"); if ((parsed.length < 3) || (parsed.length > 5)) { if (error != null) { if ((parsed.length == 1) && parsed[0].isEmpty()) { parsed = new String[0]; } switch (parsed.length) { case 0: error.set("missing namespace, name and version"); break; case 1: error.set("missing name and version"); break; default: error.set("missing version"); } } return null; } else if ((parsed.length == 5) && !"transient".equalsIgnoreCase(parsed[4])) { error.set("transient"); return null; } return (parsed.length == 3 ? new DependencyAtom(parsed[0], parsed[1], parsed[2]) : parsed.length == 4 ? ("transient".equalsIgnoreCase(parsed[3])) ? new DependencyAtom(parsed[0], parsed[1], parsed[2], true) : new DependencyAtom(parsed[0], parsed[1], parsed[2], parsed[3]) : new DependencyAtom(parsed[0], parsed[1], parsed[2], parsed[3], "transient".equalsIgnoreCase(parsed[4]))); } DependencyAtom(String namespace, String name, String version, String artifactName, boolean transientDep);  DependencyAtom(String namespace, String name, String version, String artifactName);  DependencyAtom(String namespace, String name, String version, boolean transientDep);  DependencyAtom(String namespace, String name, String version); }
DependencyAtom { public static DependencyAtom parse(String atom, AtomicReference<String> error) { if (atom == null) { return null; } atom = atom.trim(); if (atom.contains(" ")) { if (error != null) { error.set("has spaces which are not allowed in dependency atoms."); } return null; } String[] parsed = atom.split(":"); if ((parsed.length < 3) || (parsed.length > 5)) { if (error != null) { if ((parsed.length == 1) && parsed[0].isEmpty()) { parsed = new String[0]; } switch (parsed.length) { case 0: error.set("missing namespace, name and version"); break; case 1: error.set("missing name and version"); break; default: error.set("missing version"); } } return null; } else if ((parsed.length == 5) && !"transient".equalsIgnoreCase(parsed[4])) { error.set("transient"); return null; } return (parsed.length == 3 ? new DependencyAtom(parsed[0], parsed[1], parsed[2]) : parsed.length == 4 ? ("transient".equalsIgnoreCase(parsed[3])) ? new DependencyAtom(parsed[0], parsed[1], parsed[2], true) : new DependencyAtom(parsed[0], parsed[1], parsed[2], parsed[3]) : new DependencyAtom(parsed[0], parsed[1], parsed[2], parsed[3], "transient".equalsIgnoreCase(parsed[4]))); } DependencyAtom(String namespace, String name, String version, String artifactName, boolean transientDep);  DependencyAtom(String namespace, String name, String version, String artifactName);  DependencyAtom(String namespace, String name, String version, boolean transientDep);  DependencyAtom(String namespace, String name, String version); String getPropertyName(); String getPropertyValue(); String getPropertyValueWithoutTransient(); String getResolvedPropertyValue(); String getArtifactName(); DependencyAtom with(String packaging); DependencyAtom withClassifier(String classifier); DependencyAtom withoutClassifier(); String getClassifier(); String getSyntheticPackaging(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); static boolean isTransient(String atom); static String stripTransient(String atom); static DependencyAtom parse(String atom, AtomicReference<String> error); }
DependencyAtom { public static DependencyAtom parse(String atom, AtomicReference<String> error) { if (atom == null) { return null; } atom = atom.trim(); if (atom.contains(" ")) { if (error != null) { error.set("has spaces which are not allowed in dependency atoms."); } return null; } String[] parsed = atom.split(":"); if ((parsed.length < 3) || (parsed.length > 5)) { if (error != null) { if ((parsed.length == 1) && parsed[0].isEmpty()) { parsed = new String[0]; } switch (parsed.length) { case 0: error.set("missing namespace, name and version"); break; case 1: error.set("missing name and version"); break; default: error.set("missing version"); } } return null; } else if ((parsed.length == 5) && !"transient".equalsIgnoreCase(parsed[4])) { error.set("transient"); return null; } return (parsed.length == 3 ? new DependencyAtom(parsed[0], parsed[1], parsed[2]) : parsed.length == 4 ? ("transient".equalsIgnoreCase(parsed[3])) ? new DependencyAtom(parsed[0], parsed[1], parsed[2], true) : new DependencyAtom(parsed[0], parsed[1], parsed[2], parsed[3]) : new DependencyAtom(parsed[0], parsed[1], parsed[2], parsed[3], "transient".equalsIgnoreCase(parsed[4]))); } DependencyAtom(String namespace, String name, String version, String artifactName, boolean transientDep);  DependencyAtom(String namespace, String name, String version, String artifactName);  DependencyAtom(String namespace, String name, String version, boolean transientDep);  DependencyAtom(String namespace, String name, String version); String getPropertyName(); String getPropertyValue(); String getPropertyValueWithoutTransient(); String getResolvedPropertyValue(); String getArtifactName(); DependencyAtom with(String packaging); DependencyAtom withClassifier(String classifier); DependencyAtom withoutClassifier(); String getClassifier(); String getSyntheticPackaging(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); static boolean isTransient(String atom); static String stripTransient(String atom); static DependencyAtom parse(String atom, AtomicReference<String> error); static final String DEFAULT_PACKAGING; final String namespace; final String name; final String version; final String artifactName; final boolean transientDep; }