private <T> T unwrapResult(Result<T> result) { if (result.status() == Result.Status.LOCKED) { throw new ConsistentMapException.ConcurrentModification(); } else if (result.success()) { return result.value(); } else { throw new IllegalStateException("Must not be here"); } }
public File getAsFile(Artifact artifactId) { File overrideFile = findOverrideFile(artifactId); if (overrideFile != null && overrideFile.exists()) return overrideFile; Result<File> localFileName = dependencyManager.getLocalFile(artifactId); if (localFileName.success()) return localFileName.val; return null; }
public DependentLoaderImplementation enshureJarLoaded(Artifact _artifactId) { Artifact artifactId = unify(_artifactId); if ("dependent".equals(artifactId.getArtifactId()) && "no.dbwatch".equals(artifactId.getGroupId())) { return null; } DependentLoaderImplementation theLoader = findOverride(artifactId); if (theLoader != null) { visitLoader(theLoader); return theLoader; } if (loaderMap.containsKey(toString(artifactId))) return loaderMap.get(toString(artifactId)); // Fetch jar and dependencies. OutputBouble bouble = OutputBouble.push(); try { Result<File> localFileName = dependencyManager.getLocalFile(artifactId); if (localFileName.success()) theLoader = new DependentLoaderImplementation( artifactId, localFileName.val.getAbsoluteFile().toURI().toURL(), exposed, parentLoader); else theLoader = new DependentLoaderImplementation(artifactId, exposed, parentLoader); setLoader(theLoader); List<Artifact> dependencies = dependencyManager.getDirectDependencies(artifactId); DependentLoaderImplementation[] actualDependencies = new DependentLoaderImplementation[dependencies.size() + theLoader.dependencies.length]; int i = 0; for (DependentLoaderImplementation dependencyFromConf : theLoader.dependencies) { actualDependencies[i++] = dependencyFromConf; } for (Artifact dependencyId : dependencies) { DependentLoaderImplementation loader = enshureDependencyJarLoaded(artifactId, dependencyId); if (loader == null) { OutputBouble.logFile.println(artifactId.toString() + ":"); OutputBouble.logFile.println("\t Missing dependency " + dependencyId.toString()); OutputBouble.logFile.println("\t Ignoring"); } else { actualDependencies[i++] = loader; } } if (actualDependencies.length > i) { actualDependencies = Arrays.copyOf(actualDependencies, i); } theLoader.setDependencies(actualDependencies); extraDependencies.loaderAdded(theLoader); visitLoader(theLoader); return theLoader; } catch (Exception e) { OutputBouble.reportError(e); return theLoader; } finally { bouble.pop(); if (bouble.isError) bouble.writeToParent(); } // return null; }
public static <A> Heap<A> heap(A element, Comparator<A> comparator) { Heap<A> empty = empty(comparator); return new H<>(1, 1, element, empty, empty, Result.success(comparator)); }
@Override protected Result<Heap<A>> right() { return Result.success(this.right); }
public static <A> Heap<A> empty(Comparator<A> comparator) { return empty(Result.success(comparator)); }
@Override protected Result<Heap<A>> left() { return Result.success(this.left); }
@Override public Result<Heap<A>> tail() { return Result.success(Heap.merge(left, right)); }
@Override public Result<A> head() { return Result.success(this.head); }
@Override protected Result<Heap<A>> right() { return Result.success(empty(this.comparator)); }
@Override public Result<Heap<A>> left() { return Result.success(empty(this.comparator)); }