Skip to content

Commit

Permalink
Issue #331 - Refactor according bettercodehub
Browse files Browse the repository at this point in the history
  • Loading branch information
boretti committed May 31, 2020
1 parent 07423ee commit 71f4131
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
Expand Up @@ -19,6 +19,8 @@
*/
package ch.powerunit.extensions.matchers.common;

import static ch.powerunit.extensions.matchers.common.ListJoining.accepting;

import java.util.List;

import javax.lang.model.element.Element;
Expand All @@ -34,20 +36,17 @@
*/
public interface ElementHelper {

static final ListJoining<TypeMirror> TYPE_PARAMETER_BOUND_AS_LIST = ListJoining.accepting(TypeMirror.class)
.withToStringMapper().withDelimiter("&").withoutSuffixAndPrefix();
static final ListJoining<TypeMirror> TYPE_PARAMETER_BOUND_AS_LIST = accepting(TypeMirror.class).withToStringMapper()
.withDelimiter("&").withoutSuffixAndPrefix();

static final ListJoining<TypeMirror> TYPE_PARAMETER_BOUND_AS_LIST_WITH_EXTENDS = ListJoining
.accepting(TypeMirror.class).withToStringMapper().withDelimiter("&")
.withOptionalPrefixAndSuffix(" extends ", "");
static final ListJoining<TypeMirror> TYPE_PARAMETER_BOUND_AS_LIST_WITH_EXTENDS = accepting(TypeMirror.class)
.withToStringMapper().withDelimiter("&").withOptionalPrefixAndSuffix(" extends ", "");

static final ListJoining<TypeParameterElement> TYPE_PARAMETER_SIMPLE_AS_LIST = ListJoining
.accepting(TypeParameterElement.class).withToStringMapper().withCommaDelimiter()
.withOptionalPrefixAndSuffix("<", ">");
static final ListJoining<TypeParameterElement> TYPE_PARAMETER_SIMPLE_AS_LIST = accepting(TypeParameterElement.class)
.withToStringMapper().withCommaDelimiter().withOptionalPrefixAndSuffix("<", ">");

@SuppressWarnings("unchecked")
static final ListJoining<TypeParameterElement> TYPE_PARAMETER_FULL_AS_LIST = ListJoining
.accepting(TypeParameterElement.class)
static final ListJoining<TypeParameterElement> TYPE_PARAMETER_FULL_AS_LIST = accepting(TypeParameterElement.class)
.withMapper(t -> t.toString()
+ TYPE_PARAMETER_BOUND_AS_LIST_WITH_EXTENDS.asString((List<TypeMirror>) t.getBounds()))
.withCommaDelimiter().withOptionalPrefixAndSuffix("<", ">");
Expand Down
Expand Up @@ -19,6 +19,8 @@
*/
package ch.powerunit.extensions.matchers.provideprocessor.dsl;

import static ch.powerunit.extensions.matchers.common.ListJoining.joinWithMapper;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
Expand All @@ -37,13 +39,13 @@
public final class DSLMethod {
public static final Pattern DECLARATION_PARSER = Pattern.compile("^\\s*.*\\s+([0-9A-Za-z_]+)\\s*$");

private static final ListJoining<String[]> ARGUMENTS_JOIN = ListJoining
.joinWithMapper((String a[]) -> a[0] + " " + a[1]).withCommaDelimiter().withPrefixAndSuffix("(", ")");
private static final ListJoining<String[]> ARGUMENTS_JOIN = joinWithMapper((String a[]) -> a[0] + " " + a[1])
.withCommaDelimiter().withPrefixAndSuffix("(", ")");

private static final ListJoining<String[]> ARGUMENTNAMES_JOIN = ListJoining.joinWithMapper((String a[]) -> a[1])
private static final ListJoining<String[]> ARGUMENTNAMES_JOIN = joinWithMapper((String a[]) -> a[1])
.withCommaDelimiter().withPrefixAndSuffix("(", ")");

private static final ListJoining<String> IMPLEMENTATION_JOIN = ListJoining.joinWithMapper((String s) -> " " + s)
private static final ListJoining<String> IMPLEMENTATION_JOIN = joinWithMapper((String s) -> " " + s)
.withDelimiter("\n").withPrefixAndSuffix("", "\n");

private final String implementation;
Expand Down

0 comments on commit 71f4131

Please sign in to comment.