-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored: created ClassInfo and MethodSignature
- Loading branch information
Showing
6 changed files
with
126 additions
and
36 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
38 changes: 38 additions & 0 deletions
38
retrolambda/src/main/java/net/orfjackal/retrolambda/interfaces/ClassInfo.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,38 @@ | ||
// Copyright © 2013-2015 Esko Luontola <www.orfjackal.net> | ||
// This software is released under the Apache License 2.0. | ||
// The license text is at http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
package net.orfjackal.retrolambda.interfaces; | ||
|
||
import net.orfjackal.retrolambda.util.Flags; | ||
import org.objectweb.asm.*; | ||
|
||
import java.util.List; | ||
|
||
import static net.orfjackal.retrolambda.interfaces.ClassHierarchyAnalyzer.*; | ||
import static org.objectweb.asm.Opcodes.ACC_INTERFACE; | ||
|
||
public class ClassInfo { | ||
|
||
public final ClassReader reader; | ||
private final int access; | ||
public final Type type; | ||
public final Type superclass; | ||
public final List<Type> interfaces; | ||
|
||
public ClassInfo(ClassReader cr) { | ||
this.reader = cr; | ||
this.access = cr.getAccess(); | ||
this.type = classNameToType(cr.getClassName()); | ||
this.superclass = classNameToType(cr.getSuperName()); | ||
this.interfaces = classNamesToTypes(cr.getInterfaces()); | ||
} | ||
|
||
public boolean isClass() { | ||
return !isInterface(); | ||
} | ||
|
||
public boolean isInterface() { | ||
return Flags.hasFlag(access, ACC_INTERFACE); | ||
} | ||
} |
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
43 changes: 43 additions & 0 deletions
43
retrolambda/src/main/java/net/orfjackal/retrolambda/interfaces/MethodSignature.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,43 @@ | ||
// Copyright © 2013-2015 Esko Luontola <www.orfjackal.net> | ||
// This software is released under the Apache License 2.0. | ||
// The license text is at http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
package net.orfjackal.retrolambda.interfaces; | ||
|
||
import com.google.common.base.MoreObjects; | ||
|
||
import java.util.Objects; | ||
|
||
public class MethodSignature { | ||
|
||
public final String name; | ||
public final String desc; | ||
|
||
public MethodSignature(String desc, String name) { | ||
this.name = name; | ||
this.desc = desc; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (!(obj instanceof MethodSignature)) { | ||
return false; | ||
} | ||
MethodSignature that = (MethodSignature) obj; | ||
return this.name.equals(that.name) | ||
&& this.desc.equals(that.desc); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(name, desc); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return MoreObjects.toStringHelper(this) | ||
.addValue(name) | ||
.addValue(desc) | ||
.toString(); | ||
} | ||
} |
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