mirror of
https://github.com/google/nomulus.git
synced 2025-05-17 01:47:14 +02:00
Replace FluentIterable with streams
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=180005797
This commit is contained in:
parent
552ab12314
commit
3f7cd00882
13 changed files with 121 additions and 104 deletions
|
@ -21,7 +21,6 @@ import static java.nio.charset.StandardCharsets.UTF_8;
|
|||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import google.registry.flows.EppException.ParameterValueRangeErrorException;
|
||||
import google.registry.flows.EppException.ParameterValueSyntaxErrorException;
|
||||
|
@ -40,6 +39,7 @@ import google.registry.xml.XmlException;
|
|||
import google.registry.xml.XmlTransformer;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.util.List;
|
||||
|
||||
/** {@link XmlTransformer} for marshalling to and from the Epp model classes. */
|
||||
public class EppXmlTransformer {
|
||||
|
@ -87,17 +87,17 @@ public class EppXmlTransformer {
|
|||
return INPUT_TRANSFORMER.unmarshal(clazz, new ByteArrayInputStream(bytes));
|
||||
} catch (XmlException e) {
|
||||
// If this XmlException is wrapping a known type find it. If not, it's a syntax error.
|
||||
FluentIterable<Throwable> causalChain = FluentIterable.from(Throwables.getCausalChain(e));
|
||||
if (!(causalChain.filter(IpVersionMismatchException.class).isEmpty())) {
|
||||
List<Throwable> causalChain = Throwables.getCausalChain(e);
|
||||
if (causalChain.stream().anyMatch(IpVersionMismatchException.class::isInstance)) {
|
||||
throw new IpAddressVersionMismatchException();
|
||||
}
|
||||
if (!(causalChain.filter(WrongProtocolVersionException.class).isEmpty())) {
|
||||
if (causalChain.stream().anyMatch(WrongProtocolVersionException.class::isInstance)) {
|
||||
throw new UnimplementedProtocolVersionException();
|
||||
}
|
||||
if (!(causalChain.filter(InvalidRepoIdException.class).isEmpty())) {
|
||||
if (causalChain.stream().anyMatch(InvalidRepoIdException.class::isInstance)) {
|
||||
throw new InvalidRepoIdEppException();
|
||||
}
|
||||
if (!(causalChain.filter(UnknownCurrencyException.class).isEmpty())) {
|
||||
if (causalChain.stream().anyMatch(UnknownCurrencyException.class::isInstance)) {
|
||||
throw new UnknownCurrencyEppException();
|
||||
}
|
||||
throw new GenericSyntaxErrorException(e.getMessage());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue