List of usage examples for com.google.common.hash HashCode fromString
@CheckReturnValue public static HashCode fromString(String string)
From source file:com.facebook.buck.rules.modern.builders.OutOfProcessIsolatedBuilder.java
/** * Entry point for out of process rule execution. This should be run within the build root * directory (i.e. within the root cell's root). * * <p>Expected usage: {@code this_binary <build_root> <root_cell> <rule_hash> } where build_root * is the shared cell path ancestor and contains the rule_hash serialized data. */// ww w . ja v a 2s.co m public static void main(String[] args) throws IOException, StepFailedException, InterruptedException { LOG.info(String.format("Started buck at time [%s].", new java.util.Date())); Thread.setDefaultUncaughtExceptionHandler((thread, error) -> { error.printStackTrace(System.err); System.exit(1); }); Preconditions.checkState(args.length == 3, "Expected three arguments, got %d: <%s>", args.length, Joiner.on(",").join(args)); Path buildDir = Paths.get(args[0]); Path projectRoot = Paths.get(args[1]); HashCode hash = HashCode.fromString(args[2]); new IsolatedBuildableBuilder(buildDir, projectRoot) { @Override protected Console createConsole() { return new Console(Verbosity.STANDARD_INFORMATION, System.out, System.err, Ansi.withoutTty()); } @Override protected BuckEventBus createEventBus(Console console) { return new DefaultBuckEventBus(new DefaultClock(), new BuildId("whatever")); } }.build(hash); System.exit(0); }
From source file:com.facebook.buck.testutil.FakeFileHashCache.java
public static FakeFileHashCache createFromStrings(Map<String, String> pathsToHashes) { ImmutableMap.Builder<Path, HashCode> builder = ImmutableMap.builder(); for (Map.Entry<String, String> entry : pathsToHashes.entrySet()) { builder.put(Paths.get(entry.getKey()), HashCode.fromString(entry.getValue())); }/* w ww .j a v a 2s . c om*/ return new FakeFileHashCache(builder.build()); }
From source file:com.facebook.buck.testutil.FakeProjectFileHashCache.java
public static FakeProjectFileHashCache createFromStrings(ProjectFilesystem filesystem, Map<String, String> pathsToHashes) { Map<Path, HashCode> cachedValues = new HashMap<>(); for (Map.Entry<String, String> entry : pathsToHashes.entrySet()) { cachedValues.put(filesystem.getPath(entry.getKey()), HashCode.fromString(entry.getValue())); }//from www . ja v a 2 s . co m return new FakeProjectFileHashCache(filesystem, cachedValues); }
From source file:org.terasology.was.component.TreeTypeComponent.java
@Override public int hashCode() { return HashCode.fromString(treeType).asInt(); }
From source file:org.jclouds.glacier.functions.ParseMultipartUploadTreeHashHeader.java
@Override public HashCode apply(HttpResponse from) { String treehash = from.getFirstHeaderOrNull(GlacierHeaders.TREE_HASH); if (treehash == null) throw new HttpException("Did not receive Tree hash"); return HashCode.fromString(treehash); }
From source file:org.jclouds.glacier.domain.PartMetadata.java
@ConstructorProperties({ "SHA256TreeHash", "RangeInBytes" }) public PartMetadata(String treeHash, String range) { super();//from w ww . java 2s . c o m this.treeHash = HashCode.fromString(checkNotNull(treeHash, "treeHash")); this.range = ContentRange.fromString(checkNotNull(range, "range")); }
From source file:com.facebook.buck.apple.AbstractCodeSignIdentity.java
/** * Convert a {@code String} into a fingerprint {@code HashCode} if it's in the correct format. *///from w w w . j ava2 s .c om public static Optional<HashCode> toFingerprint(String identifier) { Matcher matcher = STRICT_HASH_PATTERN.matcher(identifier); if (matcher.matches()) { return Optional.of(HashCode.fromString(identifier.toLowerCase())); } else { return Optional.empty(); } }
From source file:com.facebook.buck.file.RemoteFileDescription.java
@Override public <A extends Arg> BuildRule createBuildRule(TargetGraph targetGraph, BuildRuleParams params, BuildRuleResolver resolver, A args) { HashCode sha1;/*from w w w . j a v a2 s . co m*/ try { sha1 = HashCode.fromString(args.sha1); } catch (IllegalArgumentException e) { throw new HumanReadableException(e, "%s when parsing sha1 of %s", e.getMessage(), params.getBuildTarget().getUnflavoredBuildTarget().getFullyQualifiedName()); } String out = args.out.orElse(params.getBuildTarget().getShortNameAndFlavorPostfix()); return new RemoteFile(params, downloader, args.url, sha1, out, args.type.orElse(RemoteFile.Type.DATA)); }
From source file:com.google.devtools.build.lib.analysis.ServerDirectories.java
public ServerDirectories(Path installBase, Path outputBase, @Nullable String installMD5) { this.installBase = installBase; this.outputBase = outputBase; this.installMD5 = Strings.isNullOrEmpty(installMD5) ? null : checkMD5(HashCode.fromString(installMD5)); }
From source file:org.jclouds.glacier.domain.ArchiveMetadata.java
@ConstructorProperties({ "ArchiveId", "ArchiveDescription", "CreationDate", "Size", "SHA256TreeHash" }) public ArchiveMetadata(String archiveId, @Nullable String description, Date creationDate, long size, String hashCode) {/*from w ww . j ava 2 s. c o m*/ this.archiveId = checkNotNull(archiveId, "archiveId"); this.description = description; this.creationDate = (Date) checkNotNull(creationDate, "creationDate").clone(); this.size = size; this.treeHash = HashCode.fromString(checkNotNull(hashCode, "hashCode")); }