Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright (c) 2011. Axon Framework
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  * http://www.apache.org/licenses/LICENSE-2.0
  *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.axonframework.domain;

Abstract implementation of the aggregate identifier providing basic functionality as defined by AggregateIdentifier.

This implementation contains an implementation of the compareTo(org.axonframework.domain.AggregateIdentifier), equals(java.lang.Object), hashCode() and toString() methods.

The compareTo(org.axonframework.domain.AggregateIdentifier) methods returns the result of the comparison of both identifier's string representations. For numerical values, this may not be a suitable comparison. For example, 3 would be evaluated as being larger than 10, when compared as Strings.

Author(s):
Allard Buijze
Since:
0.7
    private static final long serialVersionUID = -4777291695127713605L;

    

This implementation returns the result of AggregateIdentifier.asString().

    @Override
    public String toString() {
        return asString();
    }

    

This implementation returns the hashCode of the string representation of the identifier.

    @Override
    public int hashCode() {
        return asString().hashCode();
    }

    

This implementation compared the string representations of both identifiers.

    @Override
    public int compareTo(AggregateIdentifier other) {
        return asString().compareTo(other.asString());
    }
    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof AggregateIdentifier)) {
            return false;
        }
        AggregateIdentifier that = (AggregateIdentifiero;
        return asString().equals(that.asString());
    }
New to GrepCode? Check out our FAQ X