Compare commits
No commits in common. '7afbe9ef92c0bee6fc69651ed5ae506f6075dc22' and '74b62aa4de7052eb3282cf01b6437eda9bc730bb' have entirely different histories.
7afbe9ef92
...
74b62aa4de
@ -1,35 +0,0 @@ |
||||
package me.bearns.fias.util; |
||||
|
||||
import me.bearns.fias.domain.Addrobj; |
||||
import me.bearns.fias.domain.House; |
||||
|
||||
import java.util.Arrays; |
||||
import java.util.HashSet; |
||||
import java.util.Objects; |
||||
import java.util.Set; |
||||
import java.util.function.Predicate; |
||||
|
||||
public class RegionFilter implements Predicate { |
||||
|
||||
private final Set<String> set = new HashSet<>(); |
||||
|
||||
public RegionFilter(String codes) { |
||||
if(codes!=null){ |
||||
Arrays.stream(codes.split(",")).filter(Objects::nonNull).filter(s -> s.matches("^\\d{2}$")).forEach(set::add); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public boolean test(Object o) { |
||||
|
||||
String regioncode = null; |
||||
|
||||
if(o instanceof Addrobj){ |
||||
regioncode = ((Addrobj) o).regioncode; |
||||
} else if(o instanceof House){ |
||||
regioncode = ((House) o).regioncode; |
||||
} |
||||
|
||||
return regioncode != null && set.contains(regioncode); |
||||
} |
||||
} |
Loading…
Reference in new issue