Skip to content

Commit

Permalink
Created version 0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Ciobanu, Andrei-Nicolin (UK - EDC) committed Jun 17, 2017
1 parent e20830f commit 7021920
Show file tree
Hide file tree
Showing 15 changed files with 41 additions and 48 deletions.
2 changes: 1 addition & 1 deletion bintray.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apply plugin: 'com.jfrog.bintray'

version = '0.0.9'
version = '0.1.0'

task sourcesJar(type: Jar) {
classifier = 'sources'
Expand Down
5 changes: 2 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ plugins {
}

apply plugin: 'java'
apply plugin: "net.ltgt.errorprone"clea
apply plugin: "net.ltgt.errorprone"

group 'net.andreinc'
version '0.0.9'
version '0.1.0'

sourceCompatibility = 1.8

Expand All @@ -38,7 +38,6 @@ dependencies {
compile group: 'net.andreinc.aleph', name: 'aleph-formatter', version: '0.0.3'
compile group: 'com.google.errorprone', name: 'error_prone_annotations', version: '2.0.19'


testCompile group: 'junit', name: 'junit', version: '4.4'
testCompile group: 'commons-validator', name: 'commons-validator', version: '1.5.1'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ private MockUnitValue(MockUnit mockUnit) {
this.mockUnit = mockUnit;
}

public static final MockUnitValue unit(MockUnit unit) {
public static MockUnitValue unit(MockUnit unit) {
return new MockUnitValue(unit);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
*/


import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;

import static java.util.Collections.unmodifiableList;
import static java.util.stream.Collectors.toList;

@SuppressWarnings("ImmutableEnumChecker")
public enum CreditCardType {
Expand Down Expand Up @@ -59,8 +60,10 @@ public enum CreditCardType {

CreditCardType(Integer length, Integer... prefixes) {
this.length = length;
List<Integer> plist = Arrays.asList(prefixes);
this.prefixes = plist.stream().map(this::fromNumber).collect(Collectors.toList());
this.prefixes =
unmodifiableList(Arrays.stream(prefixes)
.map(this::fromNumber)
.collect(toList()));
}

public List<List<Integer>> getPrefixes() {
Expand All @@ -69,13 +72,13 @@ public List<List<Integer>> getPrefixes() {

public Integer getLength() { return length; }

private ArrayList<Integer> fromNumber(int num) {
private List<Integer> fromNumber(int num) {
List<Integer> list = new LinkedList<>();
int tmp = num;
while(tmp!=0) {
list.add(0, tmp%10);
tmp/=10;
}
return new ArrayList<>(list);
return unmodifiableList(list);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@
import java.util.List;

import static java.util.Arrays.asList;
import static java.util.Collections.unmodifiableList;

@SuppressWarnings("ImmutableEnumChecker")
public enum HostNameType {
ADJECTIVE_NOUN(
asList(
unmodifiableList(asList(
new Pair<>(DictType.EN_ADJECTIVE_1SYLL, DictType.EN_NOUN_1SYLL),
new Pair<>(DictType.EN_ADJECTIVE_1SYLL, DictType.EN_NOUN_2SYLL),
new Pair<>(DictType.EN_ADJECTIVE_1SYLL, DictType.EN_NOUN_3SYLL),
Expand All @@ -38,11 +39,11 @@ public enum HostNameType {
new Pair<>(DictType.EN_ADJECTIVE_3SYLL, DictType.EN_NOUN_1SYLL),
new Pair<>(DictType.EN_ADJECTIVE_3SYLL, DictType.EN_NOUN_2SYLL),
new Pair<>(DictType.EN_ADJECTIVE_3SYLL, DictType.EN_NOUN_3SYLL)
)
))
),

ADVERB_VERB(
asList(
unmodifiableList(asList(
new Pair<>(DictType.EN_ADVERB_1SYLL, DictType.EN_VERB_1SYLL),
new Pair<>(DictType.EN_ADVERB_1SYLL, DictType.EN_VERB_2SYLL),
new Pair<>(DictType.EN_ADVERB_1SYLL, DictType.EN_VERB_3SYLL),
Expand All @@ -54,11 +55,11 @@ public enum HostNameType {
new Pair<>(DictType.EN_ADVERB_3SYLL, DictType.EN_VERB_1SYLL),
new Pair<>(DictType.EN_ADVERB_3SYLL, DictType.EN_VERB_2SYLL),
new Pair<>(DictType.EN_ADVERB_3SYLL, DictType.EN_VERB_3SYLL)
)
))
),

ADJECTIVE_FIRST_NAME(
asList(
unmodifiableList(asList(
new Pair<>(DictType.EN_ADJECTIVE_1SYLL, DictType.FIRST_NAME_MALE_AMERICAN),
new Pair<>(DictType.EN_ADJECTIVE_1SYLL, DictType.FIRST_NAME_FEMALE_AMERICAN),

Expand All @@ -67,19 +68,19 @@ public enum HostNameType {

new Pair<>(DictType.EN_ADJECTIVE_3SYLL, DictType.FIRST_NAME_MALE_AMERICAN),
new Pair<>(DictType.EN_ADJECTIVE_3SYLL, DictType.FIRST_NAME_FEMALE_AMERICAN)
)
))
),

NOUN_FIRST_NAME(
asList(
unmodifiableList(asList(
new Pair<>(DictType.EN_NOUN_1SYLL, DictType.FIRST_NAME_MALE_AMERICAN),
new Pair<>(DictType.EN_NOUN_2SYLL, DictType.FIRST_NAME_MALE_AMERICAN),
new Pair<>(DictType.EN_NOUN_3SYLL, DictType.FIRST_NAME_MALE_AMERICAN),

new Pair<>(DictType.EN_NOUN_1SYLL, DictType.FIRST_NAME_FEMALE_AMERICAN),
new Pair<>(DictType.EN_NOUN_2SYLL, DictType.FIRST_NAME_FEMALE_AMERICAN),
new Pair<>(DictType.EN_NOUN_3SYLL, DictType.FIRST_NAME_FEMALE_AMERICAN)
)
))
);

private final List<Pair<DictType, DictType>> dictCombos;
Expand Down
8 changes: 0 additions & 8 deletions src/main/java/net/andreinc/mockneat/types/enums/IBANType.java
Original file line number Diff line number Diff line change
Expand Up @@ -234,21 +234,13 @@ public enum IBANType {
private final int length;
private final String prefix;
private final List<Pair<Integer, CharsType>> bban;
private String checkDigits = null;

IBANType(int length, String prefix, Pair<Integer, CharsType>... charsGroup) {
this.length = length;
this.prefix = prefix;
this.bban = asList(charsGroup);
}

IBANType(int length, String checkDigits, String prefix, Pair<Integer, CharsType>... charsGroup) {
this.length = length;
this.checkDigits = checkDigits;
this.prefix = prefix;
this.bban = asList(charsGroup);
}

public int getLength() {
return length;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

@SuppressWarnings("ImmutableEnumChecker")
public enum MACAddressFormatType {

DASH_EVERY_2_DIGITS(MACAddressFormatType::line2Digits),
COLON_EVERY_2_DIGITS(MACAddressFormatType::colon2Digits),
DOT_EVERY_2_DIGITS(MACAddressFormatType::point2Digits),
Expand Down
25 changes: 13 additions & 12 deletions src/main/java/net/andreinc/mockneat/types/enums/UserNameType.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,50 +22,51 @@
import java.util.List;

import static java.util.Arrays.asList;
import static java.util.Collections.unmodifiableList;

@SuppressWarnings("ImmutableEnumChecker")
public enum UserNameType {

ADJECTIVE_NOUN(
asList(
unmodifiableList(asList(
new Pair<>(DictType.EN_ADJECTIVE_1SYLL, DictType.EN_NOUN_1SYLL),
new Pair<>(DictType.EN_ADJECTIVE_1SYLL, DictType.EN_NOUN_2SYLL),
new Pair<>(DictType.EN_ADJECTIVE_2SYLL, DictType.EN_NOUN_1SYLL)
)
))
),

ADVERB_VERB(
asList(
unmodifiableList(asList(
new Pair<>(DictType.EN_ADVERB_1SYLL, DictType.EN_VERB_1SYLL),
new Pair<>(DictType.EN_ADVERB_2SYLL, DictType.EN_VERB_1SYLL),
new Pair<>(DictType.EN_ADVERB_1SYLL, DictType.EN_VERB_2SYLL)
)
))
),

ADJECTIVE_FIRST_NAME(
asList(
unmodifiableList(asList(
new Pair<>(DictType.EN_ADJECTIVE_1SYLL, DictType.FIRST_NAME_MALE_AMERICAN),
new Pair<>(DictType.EN_ADJECTIVE_1SYLL, DictType.FIRST_NAME_FEMALE_AMERICAN)
)
))
),

ADJECTIVE_LAST_NAME(
asList(
unmodifiableList(asList(
new Pair<>(DictType.EN_ADJECTIVE_1SYLL, DictType.LAST_NAME_AMERICAN),
new Pair<>(DictType.EN_ADJECTIVE_2SYLL, DictType.LAST_NAME_AMERICAN)
)
))
),

ADJECTIVE_FIRST_NAME_MALE(
asList(
unmodifiableList(asList(
new Pair<>(DictType.EN_ADJECTIVE_1SYLL, DictType.FIRST_NAME_MALE_AMERICAN)
)
))
),

ADJECTIVE_FIRST_NAME_FEMALE(
asList(
unmodifiableList(asList(
new Pair<>(DictType.EN_ADJECTIVE_1SYLL, DictType.FIRST_NAME_FEMALE_AMERICAN)
)
))
);

private final List<Pair<DictType, DictType>> dictCombos;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public Supplier<T> supplier() {
isTrue(JAVA_FIELD_REGEX.matcher(method).matches(), template(JAVA_METHOD_REGEX_MATCH, "method", method).fmt());
final Object[] args = new Object[params.length];
return () -> {
T result = null;
T result;
try {
range(0, params.length).forEach(i -> args[i] = MockUnitUtils.mockOrObject(params[i]));
result = (T) invokeExactStaticMethod(factoryClass, method, args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,11 @@

public class Probabilities<T> extends MockUnitBase implements MockUnit<T> {

private final Class<T> cls;
private final List<Pair<Double, MockValue>> probs = new ArrayList<>();
private final MockUnitDouble mud;

public Probabilities(MockNeat mockNeat, Class<T> cls) {
super(mockNeat);
this.cls = cls;
this.mud = mockNeat.doubles().range(0, 1.0);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public <T> MockUnit<T[]> array(T[] source) {
notNull(source, "source");
Supplier<T[]> supplier = () -> {
T[] result = source.clone();
T tmp = null;
T tmp;
for(int j, i = 0; i < result.length - 2; ++i) {
j = mockNeat.ints().range(i, result.length).val();
tmp = result[i];
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/andreinc/mockneat/unit/regex/Regex.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

public class Regex implements MockUnitString {

private String regex;
private final String regex;

public Regex(String regex) {
this.regex = regex;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/andreinc/mockneat/unit/text/Markovs.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public MockUnitString types(MarkovChainType... types) {
public MockUnitString type(MarkovChainType type) {
notNull(type, "type");
Supplier<String> supp = () -> {
MarkovUnit unit = null;
MarkovUnit unit;
try {
unit = get(type);
return unit.generateText(size);
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/net/andreinc/mockneat/unit/time/Months.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@

import static net.andreinc.mockneat.utils.ValidationUtils.*;

;

public class Months extends MockUnitBase implements MockUnitMonth {

public Months(MockNeat mockNeat) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ private String nextStrongPassword() {
int passLength = mockNeat.ints().range(minLength, maxLength).val();
StringBuilder buff = new StringBuilder();
List<Character> cAlph;
List<List<Character>> lists = asList(new List[]{SPECIAL_CHARACTERS, DIGITS, LETTERS});
List<List<Character>> lists = asList(SPECIAL_CHARACTERS, DIGITS, LETTERS);
while (passLength-- > 1) {
cAlph = mockNeat.from(lists).val();
buff.append(mockNeat.from(cAlph).val());
Expand Down

0 comments on commit 7021920

Please sign in to comment.