Java Code Examples for com.google.common.base.Objects

The following examples show how to use com.google.common.base.Objects. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Rails   Source File: ForcedRocketExchange.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
protected boolean equalsAs(PossibleAction pa, boolean asOption) {
    // identity always true
    if (pa == this) return true;
    //  super checks both class identity and super class attributes
    if (!super.equalsAs(pa, asOption)) return false;

    // no asOption attributes
    if (asOption) return true;

    // check asAction attributes
    ForcedRocketExchange action = (ForcedRocketExchange)pa;
    return Objects.equal(this.companyToReceiveTrain, action.companyToReceiveTrain)
            && Objects.equal(this.trainToReplace, action.trainToReplace)
    ;
}
 
Example 2
Source Project: o2oa   Source File: BaseAction.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private List<Class<?>> listAssemble() throws Exception {
	if (null == assembles) {
		synchronized (BaseAction.class) {
			if (null == assembles) {
				try (ScanResult scanResult = new ClassGraph().enableAnnotationInfo().scan()) {
					assembles = new CopyOnWriteArrayList<Class<?>>();
					List<ClassInfo> list = new ArrayList<>();
					list.addAll(scanResult.getClassesWithAnnotation(Module.class.getName()));
					list = list.stream().sorted(Comparator.comparing(ClassInfo::getName))
							.collect(Collectors.toList());
					for (ClassInfo info : list) {
						Class<?> cls = Class.forName(info.getName());
						Module module = cls.getAnnotation(Module.class);
						if (Objects.equal(module.type(), ModuleType.ASSEMBLE)) {
							assembles.add(cls);
						}
					}
				}
			}
		}
	}
	return assembles;
}
 
Example 3
Source Project: atomix   Source File: DefaultLeaderElectorService.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean anoint(String topic, byte[] id) {
  try {
    Leadership<byte[]> oldLeadership = leadership(topic);
    ElectionState electionState = elections.computeIfPresent(topic,
        (k, v) -> v.transferLeadership(id, termCounter(topic)));
    Leadership<byte[]> newLeadership = leadership(topic);
    if (!Objects.equal(oldLeadership, newLeadership)) {
      notifyLeadershipChange(topic, oldLeadership, newLeadership);
    }
    return (electionState != null
        && electionState.leader() != null
        && Arrays.equals(id, electionState.leader().id()));
  } catch (Exception e) {
    getLogger().error("State machine operation failed", e);
    throwIfUnchecked(e);
    throw new RuntimeException(e);
  }
}
 
Example 4
@Override
public boolean equals(final Object obj) {
	if (this == obj) {
		return true;
	}
	if (obj == null) {
		return false;
	}
	if (getClass() != obj.getClass()) {
		return false;
	}
	final AstAnnotatedToken other = (AstAnnotatedToken) obj;
	return Objects.equal(other.token, token)
			&& Objects.equal(other.tokenAstNode, tokenAstNode)
			&& Objects.equal(other.parentTokenAstNode,
					parentTokenAstNode);
}
 
Example 5
Source Project: xtext-extras   Source File: XbaseFormatter.java    License: Eclipse Public License 2.0 6 votes vote down vote up
protected XClosure builder(final List<XExpression> params) {
  XClosure _xifexpression = null;
  XExpression _last = IterableExtensions.<XExpression>last(params);
  boolean _tripleNotEquals = (_last != null);
  if (_tripleNotEquals) {
    XClosure _xblockexpression = null;
    {
      final EObject grammarElement = this.textRegionExtensions.grammarElement(IterableExtensions.<XExpression>last(params));
      XClosure _xifexpression_1 = null;
      if (((Objects.equal(grammarElement, this.grammar.getXMemberFeatureCallAccess().getMemberCallArgumentsXClosureParserRuleCall_1_1_4_0()) || 
        Objects.equal(grammarElement, this.grammar.getXFeatureCallAccess().getFeatureCallArgumentsXClosureParserRuleCall_4_0())) || 
        Objects.equal(grammarElement, this.grammar.getXConstructorCallAccess().getArgumentsXClosureParserRuleCall_5_0()))) {
        XExpression _last_1 = IterableExtensions.<XExpression>last(params);
        _xifexpression_1 = ((XClosure) _last_1);
      }
      _xblockexpression = _xifexpression_1;
    }
    _xifexpression = _xblockexpression;
  }
  return _xifexpression;
}
 
Example 6
Source Project: activitystreams   Source File: Model.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Method toString.

 * @return String */
public String toString() {
  return Objects.toStringHelper(Model.class)
    .omitNullValues()
    .add("Parent", parent)
    .add("Properties", properties)
    .toString();
}
 
Example 7
Source Project: xsemantics   Source File: MyExtendedTypeSystem.java    License: Eclipse Public License 1.0 5 votes vote down vote up
protected Result<Boolean> applyRuleMyModelSubtype(final RuleEnvironment G, final RuleApplicationTrace _trace_, final MyModel m1, final MyModel m2) throws RuleFailedException {
  String _type = m1.getType();
  String _type_1 = m2.getType();
  /* m1.type == m2.type */
  if (!Objects.equal(_type, _type_1)) {
    sneakyThrowRuleFailedException("m1.type == m2.type");
  }
  return new Result<Boolean>(true);
}
 
Example 8
@Override
public void onSubchannelState(ConnectivityStateInfo rawState) {
  if (Objects.equal(this.rawState.getState(), READY)
      && !Objects.equal(rawState.getState(), READY)) {
    // A connection was lost.  We will reset disabled flag because health check
    // may be available on the new connection.
    disabled = false;
  }
  if (Objects.equal(rawState.getState(), SHUTDOWN)) {
    helperImpl.hcStates.remove(this);
  }
  this.rawState = rawState;
  adjustHealthCheck();
}
 
Example 9
Source Project: crnk-framework   Source File: CountryTranslationPK.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean equals(Object obj) {
	if (obj == null || getClass() != obj.getClass()) {
		return false;
	}
	CountryTranslationPK other = (CountryTranslationPK) obj;
	return Objects.equal(other.lang, lang) && Objects.equal(other.country, country);
}
 
Example 10
@Override
public boolean equals(Object object) {
  if (object == null || !(object instanceof TransactionHistoryResultEntryExt)) {
    return false;
  }

  TransactionHistoryResultEntryExt other = (TransactionHistoryResultEntryExt) object;
  return Objects.equal(this.v, other.v);
}
 
Example 11
Source Project: codebuff   Source File: BaseEncoding.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public boolean equals(@Nullable Object other) {
  if (other instanceof StandardBaseEncoding) {
    StandardBaseEncoding that = (StandardBaseEncoding) other;
    return this.alphabet.equals(that.alphabet)
    && Objects.equal(this.paddingChar, that.paddingChar);
  }
  return false;
}
 
Example 12
Source Project: gerrit-rest-java-client   Source File: PermissionInfo.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean equals(Object obj) {
  if (obj instanceof PermissionInfo) {
    PermissionInfo p = (PermissionInfo) obj;
    return Objects.equal(label, p.label)
        && Objects.equal(exclusive, p.exclusive)
        && Objects.equal(rules, p.rules);
  }
  return false;
}
 
Example 13
@Override
public boolean equals(Object obj) {
  if (obj instanceof Key == false) {
    return false;
  }
  Key that = (Key) obj;
  return Objects.equal(this.url, that.url) && Objects.equal(this.username, that.username) && Objects.equal(this.password, that.password);
}
 
Example 14
Source Project: cava   Source File: Block.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean equals(Object obj) {
  if (this == obj) {
    return true;
  }
  if (!(obj instanceof Block)) {
    return false;
  }
  Block other = (Block) obj;
  return Objects.equal(header, other.header) && Objects.equal(body, other.body);
}
 
Example 15
Source Project: onos   Source File: TeLinkEventSubject.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean equals(Object object) {
    if (this == object) {
        return true;
    }
    if (object instanceof TeLinkEventSubject) {
        TeLinkEventSubject that = (TeLinkEventSubject) object;
        return Objects.equal(key, that.key) &&
                Objects.equal(teLink, that.teLink);
    }
    return false;
}
 
Example 16
Source Project: The-5zig-Mod   Source File: ClassProxy.java    License: MIT License 5 votes vote down vote up
public static void setSignText(Object signTile, String[] text) {
	for (int i = 0; i < text.length; i++) {
		fb[] components = ((asv) signTile).a;
		if (!Objects.equal(components[i].d(), text[i])) {
			components[i] = new fh(text[i]);
		}
	}
}
 
Example 17
Source Project: arctic-sea   Source File: JSONEncoderKey.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean equals(Object obj) {
    if (obj != null && obj.getClass() == getClass()) {
        JSONEncoderKey key = (JSONEncoderKey) obj;
        return Objects.equal(getType(), key.getType());
    }
    return false;
}
 
Example 18
Source Project: intellij   Source File: DirectoryEntry.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean equals(Object o) {
  if (this == o) {
    return true;
  }
  if (o == null || getClass() != o.getClass()) {
    return false;
  }
  DirectoryEntry that = (DirectoryEntry) o;
  return Objects.equal(included, that.included) && Objects.equal(directory, that.directory);
}
 
Example 19
Source Project: lttrs-android   Source File: MailboxOverwriteEntity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;
    MailboxOverwriteEntity entity = (MailboxOverwriteEntity) o;
    return value == entity.value &&
            Objects.equal(threadId, entity.threadId) &&
            Objects.equal(name, entity.name) &&
            Objects.equal(role, entity.role);
}
 
Example 20
Source Project: Gatekeeper   Source File: AccessRequest.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public int hashCode() {
    return Objects.hashCode(id,
            requestorId,
            requestorName,
            requestorEmail,
            account, region, approverComments, actionedByUserId, actionedByUserName, ticketId, requestReason, platform, hours, users, instances);
}
 
Example 21
Source Project: aws-athena-query-federation   Source File: TableName.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean equals(Object o)
{
    if (this == o) {
        return true;
    }
    if (o == null || getClass() != o.getClass()) {
        return false;
    }

    TableName that = (TableName) o;

    return Objects.equal(this.schemaName, that.schemaName) &&
            Objects.equal(this.tableName, that.tableName);
}
 
Example 22
Source Project: java-stellar-sdk   Source File: OfferEntry.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean equals(Object object) {
  if (object == null || !(object instanceof OfferEntryExt)) {
    return false;
  }

  OfferEntryExt other = (OfferEntryExt) object;
  return Objects.equal(this.v, other.v);
}
 
Example 23
Source Project: joal   Source File: AppConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean equals(final Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;
    final AppConfiguration that = (AppConfiguration) o;
    return Objects.equal(minUploadRate, that.minUploadRate) &&
            Objects.equal(maxUploadRate, that.maxUploadRate) &&
            Objects.equal(simultaneousSeed, that.simultaneousSeed) &&
            Objects.equal(client, that.client) &&
            Objects.equal(keepTorrentWithZeroLeechers, that.keepTorrentWithZeroLeechers);
}
 
Example 24
Source Project: james-project   Source File: SearchQuery.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean equals(Object obj) {
    if (obj instanceof NumericOperator) {
        NumericOperator that = (NumericOperator) obj;

        return Objects.equal(this.value, that.value)
            && Objects.equal(this.type, that.type);
    }
    return false;
}
 
Example 25
Source Project: onedev   Source File: DefaultPullRequestChangeManager.java    License: MIT License 5 votes vote down vote up
@Transactional
@Override
public void changeDescription(PullRequest request, @Nullable String description) {
	String prevDescription = request.getDescription();
	if (!Objects.equal(prevDescription, description)) {
		request.setDescription(description);
		
		PullRequestChange change = new PullRequestChange();
		change.setDate(new Date());
		change.setRequest(request);
		change.setData(new PullRequestDescriptionChangeData(prevDescription, description));
		change.setUser(SecurityUtils.getUser());
		save(change);
	}
}
 
Example 26
Source Project: james-project   Source File: UserName.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean equals(Object o) {
    if (o instanceof UserName) {
        UserName that = (UserName) o;
        return Objects.equal(value, that.value);
    }
    return false;
}
 
Example 27
Source Project: gerrit-rest-java-client   Source File: ProblemInfo.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean equals(Object o) {
  if (!(o instanceof ProblemInfo)) {
    return false;
  }
  ProblemInfo p = (ProblemInfo) o;
  return Objects.equal(message, p.message)
      && Objects.equal(status, p.status)
      && Objects.equal(outcome, p.outcome);
}
 
Example 28
Source Project: xtext-extras   Source File: HiddenLeafAccess.java    License: Eclipse Public License 2.0 5 votes vote down vote up
protected List<ILeafNode> findPreviousHiddenLeafs(final INode node) {
  List<ILeafNode> _xblockexpression = null;
  {
    INode current = node;
    while ((current instanceof ICompositeNode)) {
      current = ((ICompositeNode)current).getLastChild();
    }
    final ArrayList<ILeafNode> result = CollectionLiterals.<ILeafNode>newArrayList();
    if ((current != null)) {
      final NodeIterator ni = new NodeIterator(current);
      while (ni.hasPrevious()) {
        {
          final INode previous = ni.previous();
          if (((!Objects.equal(previous, current)) && (previous instanceof ILeafNode))) {
            boolean _isHidden = ((ILeafNode) previous).isHidden();
            if (_isHidden) {
              result.add(((ILeafNode) previous));
            } else {
              return ListExtensions.<ILeafNode>reverse(result);
            }
          }
        }
      }
    }
    _xblockexpression = ListExtensions.<ILeafNode>reverse(result);
  }
  return _xblockexpression;
}
 
Example 29
Source Project: java-platform   Source File: Application.java    License: Apache License 2.0 5 votes vote down vote up
private void initExtension() {
	if (extensions != null) {
		List<ExtensionEntity> moduleEntities = extensionService.findAllExtension();
		for (Extension module : extensions) {
			ExtensionEntity moduleEntity = findModuleEntityByCode(moduleEntities, module.getCode());
			boolean isNew = moduleEntity == null;

			boolean isUpdate = isNew || !Objects.equal(module.getVersion(), moduleEntity.getVersion());

			module.init(this, isNew, isUpdate, isNew ? null : moduleEntity.getVersion());

			if (isNew) {
				moduleEntity = extensionService.newEntity();
				moduleEntity.setCreatedBy(module.getAuthor());
				moduleEntity.setCreatedDate(new Date());
				moduleEntity.setType(Type.Extension);
			}
			if (isUpdate) {
				moduleEntity.setCode(module.getCode());
				moduleEntity.setName(module.getName());
				moduleEntity.setVersion(module.getVersion());
				moduleEntity.setLastModifiedBy(module.getAuthor());
				moduleEntity.setLastModifiedDate(new Date());

				extensionService.save(moduleEntity);
			}
		}
	}
}
 
Example 30
Source Project: java-stellar-sdk   Source File: String64.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean equals(Object object) {
  if (object == null || !(object instanceof String64)) {
    return false;
  }

  String64 other = (String64) object;
  return Objects.equal(this.string64, other.string64);
}