-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce support for constants in the MDC. #7
Open
marchermans
wants to merge
1
commit into
dev
Choose a base branch
from
feature/unpick
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -215,11 +215,14 @@ public static class ImmutableFieldData implements MappingDataContainer.FieldData | |
private final String name; | ||
private final String descriptor; | ||
private final List<String> javadoc; | ||
@Nullable | ||
private final ConstantData constant; | ||
|
||
public ImmutableFieldData(String name, String descriptor, List<String> javadoc) { | ||
public ImmutableFieldData(String name, String descriptor, List<String> javadoc, @Nullable ConstantData constant) { | ||
this.name = name; | ||
this.descriptor = descriptor; | ||
this.javadoc = ImmutableList.copyOf(javadoc); | ||
this.constant = constant; | ||
} | ||
|
||
/** | ||
|
@@ -246,18 +249,36 @@ public List<String> getJavadoc() { | |
return javadoc; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public ConstantData getConstant() { | ||
return constant; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (!(o instanceof FieldData)) return false; | ||
FieldData that = (FieldData) o; | ||
return getName().equals(that.getName()) && Objects.equals(getDescriptor(), that.getDescriptor()) | ||
&& getJavadoc().equals(that.getJavadoc()); | ||
if (!(o instanceof ImmutableFieldData)) return false; | ||
|
||
ImmutableFieldData that = (ImmutableFieldData) o; | ||
|
||
if (getName() != null ? !getName().equals(that.getName()) : that.getName() != null) return false; | ||
if (getDescriptor() != null ? !getDescriptor().equals(that.getDescriptor()) : that.getDescriptor() != null) | ||
return false; | ||
if (getJavadoc() != null ? !getJavadoc().equals(that.getJavadoc()) : that.getJavadoc() != null) | ||
return false; | ||
return getConstant() != null ? getConstant().equals(that.getConstant()) : that.getConstant() == null; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(getName(), getDescriptor(), getJavadoc()); | ||
int result = getName() != null ? getName().hashCode() : 0; | ||
result = 31 * result + (getDescriptor() != null ? getDescriptor().hashCode() : 0); | ||
result = 31 * result + (getJavadoc() != null ? getJavadoc().hashCode() : 0); | ||
result = 31 * result + (getConstant() != null ? getConstant().hashCode() : 0); | ||
return result; | ||
Comment on lines
-260
to
+281
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why change from Same comment on all other similar instances. |
||
} | ||
} | ||
|
||
|
@@ -344,11 +365,14 @@ public static class ImmutableParameterData implements MappingDataContainer.Param | |
private final String name; | ||
@Nullable | ||
private final String javadoc; | ||
@Nullable | ||
private final ConstantData constant; | ||
|
||
public ImmutableParameterData(byte index, @Nullable String name, @Nullable String javadoc) { | ||
public ImmutableParameterData(byte index, @Nullable String name, @Nullable String javadoc, @Nullable ConstantData constant) { | ||
this.index = index; | ||
this.name = name; | ||
this.javadoc = javadoc; | ||
this.constant = constant; | ||
} | ||
|
||
/** | ||
|
@@ -377,17 +401,131 @@ public String getJavadoc() { | |
return javadoc; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public ConstantData getConstant() { | ||
return constant; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (!(o instanceof ImmutableParameterData)) return false; | ||
|
||
ImmutableParameterData that = (ImmutableParameterData) o; | ||
|
||
if (getIndex() != that.getIndex()) return false; | ||
if (getName() != null ? !getName().equals(that.getName()) : that.getName() != null) return false; | ||
if (getJavadoc() != null ? !getJavadoc().equals(that.getJavadoc()) : that.getJavadoc() != null) | ||
return false; | ||
return getConstant() != null ? getConstant().equals(that.getConstant()) : that.getConstant() == null; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result = getIndex(); | ||
result = 31 * result + (getName() != null ? getName().hashCode() : 0); | ||
result = 31 * result + (getJavadoc() != null ? getJavadoc().hashCode() : 0); | ||
result = 31 * result + (getConstant() != null ? getConstant().hashCode() : 0); | ||
return result; | ||
} | ||
} | ||
|
||
/** | ||
* An immutable {@link MappingDataContainer.ConstantData}. | ||
*/ | ||
public static final class ImmutableConstantData implements ConstantData { | ||
|
||
private final ConstantType type; | ||
private final List<ConstantValueData> values; | ||
|
||
public ImmutableConstantData(ConstantType type, List<ConstantValueData> values) { | ||
this.type = type; | ||
this.values = values; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public ConstantType getType() { | ||
return type; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public List<ConstantValueData> getValues() { | ||
return values; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (!(o instanceof ParameterData)) return false; | ||
ParameterData that = (ParameterData) o; | ||
return getIndex() == that.getIndex() && Objects.equals(getName(), that.getName()) && Objects.equals(getJavadoc(), that.getJavadoc()); | ||
if (!(o instanceof ImmutableConstantData)) return false; | ||
|
||
ImmutableConstantData that = (ImmutableConstantData) o; | ||
|
||
if (getType() != that.getType()) return false; | ||
return getValues().equals(that.getValues()); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result = getType().hashCode(); | ||
result = 31 * result + getValues().hashCode(); | ||
return result; | ||
} | ||
} | ||
|
||
/** | ||
* An immutable {@link MappingDataContainer.ConstantValueData}. | ||
*/ | ||
public static final class ImmutableConstantValueData implements ConstantValueData { | ||
|
||
private final int value; | ||
private final String reference; | ||
|
||
public ImmutableConstantValueData(int value, String reference) { | ||
this.value = value; | ||
this.reference = reference; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public int getValue() { | ||
return value; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public String getReference() { | ||
return reference; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (!(o instanceof ImmutableConstantValueData)) return false; | ||
|
||
ImmutableConstantValueData that = (ImmutableConstantValueData) o; | ||
|
||
if (getValue() != that.getValue()) return false; | ||
return getReference().equals(that.getReference()); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(getIndex(), getName(), getJavadoc()); | ||
int result = getValue(); | ||
result = 31 * result + getReference().hashCode(); | ||
return result; | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change would mean
ImmutableFieldData
would be incomparable to otherFieldData
instances (such as mutable ones). It should only check if it is an instance ofFieldData
.Same comment on all other similar instances.