-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ARC-1700: Pull impls into internal records.
- Loading branch information
1 parent
c0ffee0
commit c0ffee8
Showing
4 changed files
with
28 additions
and
64 deletions.
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
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 |
---|---|---|
@@ -1,45 +1,16 @@ | ||
package com.oviva.spicegen.api; | ||
|
||
import java.util.Objects; | ||
import com.oviva.spicegen.api.internal.SubjectRefImpl; | ||
|
||
public interface SubjectRef { | ||
String kind(); | ||
|
||
String id(); | ||
|
||
static SubjectRef ofObject(ObjectRef o) { | ||
return new SubjectRef() { | ||
@Override | ||
public String kind() { | ||
return o.kind(); | ||
} | ||
|
||
@Override | ||
public String id() { | ||
return o.id(); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(o); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (!(obj instanceof SubjectRef that)) { | ||
return false; | ||
} | ||
return Objects.equals(this.kind(), that.kind()) && Objects.equals(this.id(), that.id()); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
if (o == null) { | ||
return ""; | ||
} | ||
|
||
return o.toString(); | ||
} | ||
}; | ||
if (o == null) { | ||
return null; | ||
} | ||
return new SubjectRefImpl(o.kind(), o.id()); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
api/src/main/java/com/oviva/spicegen/api/internal/ObjectRefImpl.java
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.oviva.spicegen.api.internal; | ||
|
||
import com.oviva.spicegen.api.ObjectRef; | ||
|
||
public record ObjectRefImpl(String kind, String id) implements ObjectRef { | ||
|
||
@Override | ||
public String toString() { | ||
return "%s:%s".formatted(kind, id); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
api/src/main/java/com/oviva/spicegen/api/internal/SubjectRefImpl.java
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.oviva.spicegen.api.internal; | ||
|
||
import com.oviva.spicegen.api.SubjectRef; | ||
|
||
public record SubjectRefImpl(String kind, String id) implements SubjectRef { | ||
@Override | ||
public String toString() { | ||
return "%s:%s".formatted(kind, id); | ||
} | ||
} |