Package software.amazon.smithy.diff
Class ChangedShape<S extends Shape>
- java.lang.Object
-
- software.amazon.smithy.diff.ChangedShape<S>
-
- Type Parameters:
S
- The type of shape. Note that this may be justShape
in the event that the shape changed classes.
- All Implemented Interfaces:
FromSourceLocation
public final class ChangedShape<S extends Shape> extends java.lang.Object implements FromSourceLocation
Represents a changed shape.
-
-
Constructor Summary
Constructors Constructor Description ChangedShape(S oldShape, S newShape)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.stream.Stream<Trait>
addedTraits()
Gets a stream of added traits.java.util.stream.Stream<Pair<Trait,Trait>>
changedTraits()
Gets a stream of changed traits.boolean
equals(java.lang.Object o)
<T extends Trait>
java.util.Optional<Pair<T,T>>getChangedTrait(java.lang.Class<T> traitType)
Gets a changed trait of a specific type.S
getNewShape()
Gets the new shape value.S
getOldShape()
Gets the old shape value.ShapeId
getShapeId()
Gets the shape ID of the changed shape.SourceLocation
getSourceLocation()
Gets the source location of a value.java.util.Map<ShapeId,Pair<Trait,Trait>>
getTraitDifferences()
Gets the trait differences between the old and new shape.int
hashCode()
boolean
isTraitAdded(ShapeId trait)
Checks if the trait was added.boolean
isTraitInBoth(ShapeId trait)
Checks if the given trait is in the old shape and new shape.boolean
isTraitRemoved(ShapeId trait)
Checks if the trait was removed.java.util.stream.Stream<Trait>
removedTraits()
Gets a stream of removed traits.
-
-
-
Method Detail
-
getOldShape
public S getOldShape()
Gets the old shape value.- Returns:
- Returns the old shape.
-
getNewShape
public S getNewShape()
Gets the new shape value.- Returns:
- Returns the new shape.
-
getSourceLocation
public SourceLocation getSourceLocation()
Description copied from interface:FromSourceLocation
Gets the source location of a value.- Specified by:
getSourceLocation
in interfaceFromSourceLocation
- Returns:
- Returns the source location of the value.
-
getShapeId
public ShapeId getShapeId()
Gets the shape ID of the changed shape.- Returns:
- Return the shape ID.
-
addedTraits
public java.util.stream.Stream<Trait> addedTraits()
Gets a stream of added traits.- Returns:
- Returns the traits that were added.
-
removedTraits
public java.util.stream.Stream<Trait> removedTraits()
Gets a stream of removed traits.- Returns:
- Returns the traits that were removed.
-
changedTraits
public java.util.stream.Stream<Pair<Trait,Trait>> changedTraits()
Gets a stream of changed traits.- Returns:
- Returns the traits that were changed.
-
isTraitAdded
public boolean isTraitAdded(ShapeId trait)
Checks if the trait was added.- Parameters:
trait
- Trait to check.- Returns:
- Returns true if the trait was added.
-
isTraitRemoved
public boolean isTraitRemoved(ShapeId trait)
Checks if the trait was removed.- Parameters:
trait
- Trait to check.- Returns:
- Returns true if the trait was removed.
-
isTraitInBoth
public boolean isTraitInBoth(ShapeId trait)
Checks if the given trait is in the old shape and new shape.- Parameters:
trait
- Trait to check.- Returns:
- Returns true if the trait is in the old and new shape.
-
getChangedTrait
public <T extends Trait> java.util.Optional<Pair<T,T>> getChangedTrait(java.lang.Class<T> traitType)
Gets a changed trait of a specific type.- Type Parameters:
T
- Type of trait to find.- Parameters:
traitType
- Type of trait to find.- Returns:
- Returns the optionally found old and new typed trait values.
-
getTraitDifferences
public java.util.Map<ShapeId,Pair<Trait,Trait>> getTraitDifferences()
Gets the trait differences between the old and new shape.The returned map is a mapping of a trait name to a pair in which the left side of the pair contains the nullable old trait value, and the right side of the pair contains the nullable new trait value. The left side will be null if the trait was added, the right side will be null if the trait was removed, and both traits will be present if the trait changed.
- Returns:
- Returns a map of each changed trait name to a pair of the old and new trait values.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-