forked from immutables/immutables
-
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.
removed unnecessary abstraction reuse for declaring type
- Loading branch information
Showing
7 changed files
with
1,974 additions
and
1,664 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
66 changes: 66 additions & 0 deletions
66
value-processor/src/org/immutables/value/processor/encode/DefaultTypeFactory.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,66 @@ | ||
package org.immutables.value.processor.encode; | ||
|
||
import com.google.common.collect.ImmutableMap; | ||
import java.util.Map; | ||
import javax.annotation.Nullable; | ||
import org.immutables.value.processor.encode.Type.Array; | ||
import org.immutables.value.processor.encode.Type.Defined; | ||
import org.immutables.value.processor.encode.Type.Nonprimitive; | ||
import org.immutables.value.processor.encode.Type.Primitive; | ||
import org.immutables.value.processor.encode.Type.Reference; | ||
import org.immutables.value.processor.encode.Type.Variable; | ||
import org.immutables.value.processor.encode.Type.Wildcard; | ||
|
||
class DefaultTypeFactory implements Type.Factory { | ||
private static final Map<String, Type> PREDEFINED_TYPES; | ||
static { | ||
ImmutableMap.Builder<String, Type> predefined = | ||
ImmutableMap.<String, Type>builder().put(Type.OBJECT.name, Type.OBJECT); | ||
for (Primitive p : Primitive.values()) { | ||
predefined.put(p.typename, p); | ||
} | ||
PREDEFINED_TYPES = predefined.build(); | ||
} | ||
|
||
@Override | ||
public Type named(String name) { | ||
@Nullable Type type = PREDEFINED_TYPES.get(name); | ||
if (type != null) return type; | ||
return defined(name); | ||
} | ||
|
||
private Type defined(String name) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Type.Parameterized parameterized(Reference raw, Iterable<? extends Nonprimitive> arguments) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Array array(Type element) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Wildcard.Super superWildcard(Defined lowerBound) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Wildcard.Extends extendsWildcard(Defined upperBound) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Variable variable(String name) { | ||
return null; // TODO auto | ||
} | ||
|
||
@Override | ||
public Reference unresolved(String name) { | ||
return null; // TODO auto | ||
} | ||
|
||
} |
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
33 changes: 33 additions & 0 deletions
33
value-processor/src/org/immutables/value/processor/encode/Eq.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,33 @@ | ||
package org.immutables.value.processor.encode; | ||
|
||
import java.util.Objects; | ||
|
||
public abstract class Eq<Q extends Eq<Q>> { | ||
private final int hash; | ||
|
||
protected Eq(Object... hash) { | ||
this.hash = Objects.hash(hash); | ||
} | ||
|
||
protected abstract boolean eq(Q other); | ||
|
||
@SuppressWarnings("unchecked") | ||
@Override | ||
public final boolean equals(Object obj) { | ||
if (this == obj) { | ||
return true; | ||
} | ||
if (obj == null) { | ||
return false; | ||
} | ||
if (getClass() == obj.getClass()) { | ||
return eq((Q) obj); | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public final int hashCode() { | ||
return hash; | ||
} | ||
} |
Oops, something went wrong.