Skip to content

Commit

Permalink
Drop dependency on Guava
Browse files Browse the repository at this point in the history
  • Loading branch information
stephan-gh authored and jamierocks committed Aug 26, 2018
1 parent 672dc97 commit 84d1469
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

import com.github.benmanes.caffeine.cache.Caffeine;
import com.github.benmanes.caffeine.cache.LoadingCache;
import com.google.common.io.ByteStreams;
import me.jamiemansfield.bombe.analysis.InheritanceProvider;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.tree.ClassNode;
Expand Down Expand Up @@ -62,7 +61,7 @@ public ClassLoaderInheritanceProvider(final ClassLoader classLoader) {
// I read the class using ASM as getting the information required using
// reflection is awkward.
// Additionally, it allows me to share code - which is always a positive!
final ClassReader reader = new ClassReader(ByteStreams.toByteArray(in));
final ClassReader reader = new ClassReader(in);
final ClassNode node = new ClassNode();
reader.accept(node, 0);

Expand Down
1 change: 0 additions & 1 deletion bombe-core/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
dependencies {
compile 'com.google.guava:guava:22.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@

package me.jamiemansfield.bombe.type;

import com.google.common.base.Strings;

import java.util.Arrays;
import java.util.Objects;

/**
Expand All @@ -58,7 +57,11 @@ public class ArrayType implements FieldType {
*/
public ArrayType(final int arrayDims, final Type component) {
this.dimCount = arrayDims;
this.arrayDims = Strings.repeat("[", arrayDims);

char[] dims = new char[arrayDims];
Arrays.fill(dims, '[');
this.arrayDims = new String(dims);

this.component = component;
this.descriptor = this.arrayDims + component.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@

package me.jamiemansfield.bombe.type.signature;

import com.google.common.base.MoreObjects;
import me.jamiemansfield.bombe.type.FieldType;

import java.util.Objects;
import java.util.Optional;
import java.util.StringJoiner;

/**
* Represents a field within a class, by its name and descriptor.
Expand Down Expand Up @@ -87,9 +87,9 @@ public Optional<FieldType> getType() {
}

@Override
protected MoreObjects.ToStringHelper buildToString() {
protected StringJoiner buildToString() {
return super.buildToString()
.add("type", this.type);
.add("type=" + this.type);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

package me.jamiemansfield.bombe.type.signature;

import com.google.common.base.MoreObjects;
import java.util.StringJoiner;

/**
* All members within Java have a unique signature that they can be identified with,
Expand Down Expand Up @@ -64,13 +64,13 @@ public String getName() {
return this.name;
}

protected MoreObjects.ToStringHelper buildToString() {
return MoreObjects.toStringHelper(this)
.add("name", this.name);
protected StringJoiner buildToString() {
return new StringJoiner(", ", getClass().getSimpleName() + "{", "}")
.add("name=" + name);
}

@Override
public String toString() {
public final String toString() {
return this.buildToString().toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@

package me.jamiemansfield.bombe.type.signature;

import com.google.common.base.MoreObjects;
import me.jamiemansfield.bombe.type.MethodDescriptor;

import java.util.Objects;
import java.util.StringJoiner;

/**
* Represents a method within a class, by its name and descriptor.
Expand Down Expand Up @@ -76,11 +76,9 @@ public MethodDescriptor getDescriptor() {
}

@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("name", this.name)
.add("descriptor", this.descriptor)
.toString();
protected StringJoiner buildToString() {
return super.buildToString()
.add("descriptor=" + this.descriptor);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import com.google.common.collect.ImmutableMap;
import me.jamiemansfield.bombe.type.ArrayType;
import me.jamiemansfield.bombe.type.BaseType;
import me.jamiemansfield.bombe.type.FieldType;
Expand All @@ -43,23 +42,27 @@
import me.jamiemansfield.bombe.type.VoidType;
import org.junit.jupiter.api.Test;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/**
* Unit tests pertaining to the type model in Bombe.
*/
public final class TypeTest {

private static final Map<Class<?>, BaseType> BASE_MAPPINGS = ImmutableMap.<Class<?>, BaseType>builder()
.put(Boolean.TYPE, BaseType.BOOLEAN)
.put(Character.TYPE, BaseType.CHAR)
.put(Byte.TYPE, BaseType.BYTE)
.put(Short.TYPE, BaseType.SHORT)
.put(Integer.TYPE, BaseType.INT)
.put(Long.TYPE, BaseType.LONG)
.put(Float.TYPE, BaseType.FLOAT)
.put(Double.TYPE, BaseType.DOUBLE)
.build();
private static final Map<Class<?>, BaseType> BASE_MAPPINGS = Collections.unmodifiableMap(new HashMap<Class<?>, BaseType>() {
{
this.put(Boolean.TYPE, BaseType.BOOLEAN);
this.put(Character.TYPE, BaseType.CHAR);
this.put(Byte.TYPE, BaseType.BYTE);
this.put(Short.TYPE, BaseType.SHORT);
this.put(Integer.TYPE, BaseType.INT);
this.put(Long.TYPE, BaseType.LONG);
this.put(Float.TYPE, BaseType.FLOAT);
this.put(Double.TYPE, BaseType.DOUBLE);
}
});

@Test
public void arrayType() {
Expand Down

0 comments on commit 84d1469

Please sign in to comment.