下面列出了怎么用com.google.common.base.Objects的API类实例代码及写法,或者点击链接到github查看源代码。
@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)
;
}
@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;
}
@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);
}
}
@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);
}
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;
}
/**
* Method toString.
* @return String */
public String toString() {
return Objects.toStringHelper(Model.class)
.omitNullValues()
.add("Parent", parent)
.add("Properties", properties)
.toString();
}
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);
}
@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();
}
@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);
}
@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);
}
@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;
}
@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;
}
@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);
}
@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);
}
@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;
}
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]);
}
}
}
@Override
public boolean equals(Object obj) {
if (obj != null && obj.getClass() == getClass()) {
JSONEncoderKey key = (JSONEncoderKey) obj;
return Objects.equal(getType(), key.getType());
}
return false;
}
@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);
}
@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);
}
@Override
public int hashCode() {
return Objects.hashCode(id,
requestorId,
requestorName,
requestorEmail,
account, region, approverComments, actionedByUserId, actionedByUserName, ticketId, requestReason, platform, hours, users, instances);
}
@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);
}
@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);
}
@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);
}
@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;
}
@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);
}
}
@Override
public boolean equals(Object o) {
if (o instanceof UserName) {
UserName that = (UserName) o;
return Objects.equal(value, that.value);
}
return false;
}
@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);
}
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;
}
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);
}
}
}
}
@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);
}