コード例 #1
0
ファイル: RuleKey.java プロジェクト: Nouhi/buck
 /**
  * Treat non-idempotent RuleKeys as unequal to everything, including other non-idempotent
  * RuleKeys.
  */
 @Override
 public boolean equals(Object that) {
   if (!(that instanceof RuleKey)) {
     return false;
   }
   RuleKey other = (RuleKey) that;
   if (!isIdempotent() || !other.isIdempotent()) {
     return false;
   }
   return (compareTo(other) == 0);
 }
コード例 #2
0
ファイル: RuleKey.java プロジェクト: Nouhi/buck
 /**
  * Order non-idempotent RuleKeys as less than all idempotent RuleKeys.
  *
  * <p>non-idempotent < idempotent
  */
 @Override
 public int compareTo(RuleKey other) {
   if (!isIdempotent()) {
     if (!other.isIdempotent()) {
       return 0;
     }
     return -1;
   } else if (!other.isIdempotent()) {
     return 1;
   }
   return ByteBuffer.wrap(hashCode.asBytes()).compareTo(ByteBuffer.wrap(other.hashCode.asBytes()));
 }
コード例 #3
0
ファイル: RuleKey.java プロジェクト: Nouhi/buck
 public RuleKey build() {
   RuleKey ruleKey = idempotent ? new RuleKey(hasher.hash()) : new RuleKey(null);
   if (logElms != null) {
     logger.info(
         String.format(
             "%sRuleKey %s=%s",
             ruleKey.isIdempotent() ? "" : "non-idempotent ",
             ruleKey.toString(),
             Joiner.on("").join(logElms)));
   }
   return ruleKey;
 }
コード例 #4
0
ファイル: RuleKey.java プロジェクト: Nouhi/buck
 private Builder setVal(@Nullable RuleKey ruleKey) {
   if (ruleKey != null) {
     if (logElms != null) {
       logElms.add(
           String.format(
               "%sruleKey(sha1=%s):",
               ruleKey.isIdempotent() ? "" : "non-idempotent ", ruleKey.toString()));
     }
     feed(ruleKey.toString().getBytes()).mergeIdempotence(ruleKey.isIdempotent());
   }
   return separate();
 }
コード例 #5
0
ファイル: RuleKey.java プロジェクト: Nouhi/buck
 /** Helper method used to avoid memoizing non-idempotent RuleKeys. */
 @Nullable
 public static RuleKey filter(RuleKey ruleKey) {
   if (!ruleKey.isIdempotent()) {
     return null;
   }
   return ruleKey;
 }
コード例 #6
0
ファイル: RuleKeyTest.java プロジェクト: JoeHorn/buck
 @Test
 public void testRuleKeyEqualsAndHashCodeMethods() {
   SourcePathResolver resolver =
       new SourcePathResolver(
           new BuildRuleResolver(TargetGraph.EMPTY, new BuildTargetNodeToBuildRuleTransformer()));
   RuleKey keyPair1 = createEmptyRuleKey(resolver).setReflectively("something", "foo").build();
   RuleKey keyPair2 = createEmptyRuleKey(resolver).setReflectively("something", "foo").build();
   RuleKey keyPair3 = createEmptyRuleKey(resolver).setReflectively("something", "bar").build();
   assertEquals(keyPair1, keyPair2);
   assertEquals(keyPair1.hashCode(), keyPair2.hashCode());
   assertNotEquals(keyPair1, keyPair3);
   assertNotEquals(keyPair1.hashCode(), keyPair3.hashCode());
   assertNotEquals(keyPair2, keyPair3);
   assertNotEquals(keyPair2.hashCode(), keyPair3.hashCode());
 }
コード例 #7
0
ファイル: RuleKeyTest.java プロジェクト: JoeHorn/buck
 @Test
 public void testRuleKeyFromHashString() {
   RuleKey ruleKey = new RuleKey("19d2558a6bd3a34fb3f95412de9da27ed32fe208");
   assertEquals("19d2558a6bd3a34fb3f95412de9da27ed32fe208", ruleKey.toString());
 }