Skip to content

Commit

Permalink
style: format code and optimize imports in matchers.OmnibusMatcher
Browse files Browse the repository at this point in the history
  • Loading branch information
vvatanabe committed Aug 19, 2023
1 parent b5d7482 commit d255ace
Showing 1 changed file with 23 additions and 25 deletions.
48 changes: 23 additions & 25 deletions src/main/java/com/nulabinc/zxcvbn/matchers/OmnibusMatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,37 @@

import com.nulabinc.zxcvbn.Context;
import com.nulabinc.zxcvbn.Matcher;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class OmnibusMatcher extends BaseMatcher {

private final Map<String, Map<String, Integer>> dictionaryMap;

public OmnibusMatcher(Context context, Map<String, Map<String, Integer>> dictionaries) {
super(context);
if (dictionaries == null) {
this.dictionaryMap = new HashMap<>();
} else {
this.dictionaryMap = dictionaries;
}
}
private final Map<String, Map<String, Integer>> dictionaryMap;

@Override
public List<Match> execute(CharSequence password) {
List<Matcher> matchers = new ArrayList<>();
matchers.add(new DictionaryMatcher(this.getContext(), dictionaryMap));
matchers.add(new ReverseDictionaryMatcher(this.getContext(), dictionaryMap));
matchers.add(new L33tMatcher(this.getContext(), dictionaryMap));
matchers.add(new SpatialMatcher(this.getContext()));
matchers.add(new RepeatMatcher(this.getContext()));
matchers.add(new SequenceMatcher(this.getContext()));
matchers.add(new RegexMatcher(this.getContext()));
matchers.add(new DateMatcher(this.getContext()));
List<Match> matches = new ArrayList<>();
for (Matcher matcher: matchers) matches.addAll(matcher.execute(password));
return this.sorted(matches);
public OmnibusMatcher(Context context, Map<String, Map<String, Integer>> dictionaries) {
super(context);
if (dictionaries == null) {
this.dictionaryMap = new HashMap<>();
} else {
this.dictionaryMap = dictionaries;
}
}

@Override
public List<Match> execute(CharSequence password) {
List<Matcher> matchers = new ArrayList<>();
matchers.add(new DictionaryMatcher(this.getContext(), dictionaryMap));
matchers.add(new ReverseDictionaryMatcher(this.getContext(), dictionaryMap));
matchers.add(new L33tMatcher(this.getContext(), dictionaryMap));
matchers.add(new SpatialMatcher(this.getContext()));
matchers.add(new RepeatMatcher(this.getContext()));
matchers.add(new SequenceMatcher(this.getContext()));
matchers.add(new RegexMatcher(this.getContext()));
matchers.add(new DateMatcher(this.getContext()));
List<Match> matches = new ArrayList<>();
for (Matcher matcher : matchers) matches.addAll(matcher.execute(password));
return this.sorted(matches);
}
}

0 comments on commit d255ace

Please sign in to comment.