Skip to content
This repository has been archived by the owner on Mar 15, 2021. It is now read-only.

Commit

Permalink
Replaced lambdas with method references
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Parm committed Jul 13, 2016
1 parent 18ecf9b commit 4262e58
Show file tree
Hide file tree
Showing 12 changed files with 12 additions and 21 deletions.
5 changes: 0 additions & 5 deletions api/src/main/java/com/spotify/ffwd/filter/TrueFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import lombok.Data;

import java.io.IOException;
import java.util.function.Supplier;

@Data
public class TrueFilter implements Filter {
Expand All @@ -49,8 +48,4 @@ public Filter deserialize(JsonParser p, DeserializationContext ctx)
return new TrueFilter();
}
}

public static Supplier<TrueFilter> supplier() {
return TrueFilter::new;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public InputManagerModule(
@JsonProperty("plugins") List<InputPlugin> plugins, @JsonProperty("filter") Filter filter
) {
this.plugins = Optional.ofNullable(plugins).orElse(DEFAULT_PLUGINS);
this.filter = Optional.ofNullable(filter).orElseGet(() -> new TrueFilter());
this.filter = Optional.ofNullable(filter).orElseGet(TrueFilter::new);
}

public Module module() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public OutputManagerModule(
@JsonProperty("plugins") List<OutputPlugin> plugins, @JsonProperty("filter") Filter filter
) {
this.plugins = Optional.ofNullable(plugins).orElse(DEFAULT_PLUGINS);
this.filter = Optional.ofNullable(filter).orElseGet(() -> new TrueFilter());
this.filter = Optional.ofNullable(filter).orElseGet(TrueFilter::new);
}

public Module module() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ public byte[] serialize(Metric metric) throws Exception {
}

public static Supplier<Serializer> defaultSupplier() {
return () -> new ToStringSerializer();
return ToStringSerializer::new;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public CarbonInputPlugin(
.protocol(DEFAULT_PROTOCOL, DEFAULT_PORT);
this.protocolServer =
parseProtocolServer(Optional.ofNullable(delimiter).orElseGet(this::defaultDelimiter));
this.retry = Optional.ofNullable(retry).orElseGet(() -> new RetryPolicy.Exponential());
this.retry = Optional.ofNullable(retry).orElseGet(RetryPolicy.Exponential::new);
this.metricKey = Optional.ofNullable(key).orElse(DEFAULT_KEY);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public JsonInputPlugin(
.protocol(DEFAULT_PROTOCOL, DEFAULT_PORT);
this.protocolServer =
parseProtocolServer(Optional.ofNullable(delimiter).orElseGet(this::defaultDelimiter));
this.retry = Optional.ofNullable(retry).orElseGet(() -> new RetryPolicy.Exponential());
this.retry = Optional.ofNullable(retry).orElseGet(RetryPolicy.Exponential::new);
}

private String defaultDelimiter() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ public KafkaOutputPlugin(
) {
this.router = Optional.ofNullable(router).orElseGet(KafkaRouter.Tag.supplier());
this.partitioner = Optional.ofNullable(partitioner)
.orElseGet(KafkaPartitioner.Host.supplier());
.orElseGet(KafkaPartitioner.Host::new);
this.flushInterval = Optional.ofNullable(flushInterval);
this.properties = Optional.ofNullable(properties).orElseGet(() -> new HashMap<>());
this.properties = Optional.ofNullable(properties).orElseGet(HashMap::new);
this.serializer = Optional.ofNullable(serializer);
this.batchSize = Optional.ofNullable(batchSize).orElse(DEFAULT_BATCH_SIZE);
this.compression = Optional.ofNullable(compression).orElse(DEFAULT_COMPRESSION);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ public int partition(final Event event) {
public int partition(final Metric metric) {
return metric.getHost().hashCode();
}

public static Supplier<KafkaPartitioner> supplier() {
return Host::new;
}
}

class Tag implements KafkaPartitioner {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public ProtobufInputPlugin(
.orElseGet(ProtocolFactory.defaultFor())
.protocol(DEFAULT_PROTOCOL, DEFAULT_PORT);
this.protocolServer = parseProtocolServer();
this.retry = Optional.ofNullable(retry).orElseGet(() -> new RetryPolicy.Exponential());
this.retry = Optional.ofNullable(retry).orElseGet(RetryPolicy.Exponential::new);
}

private Class<? extends ProtocolServer> parseProtocolServer() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public RiemannInputPlugin(
.orElseGet(ProtocolFactory.defaultFor())
.protocol(DEFAULT_PROTOCOL, DEFAULT_PORT);
this.protocolServer = parseProtocolServer();
this.retry = Optional.ofNullable(retry).orElseGet(() -> new RetryPolicy.Exponential());
this.retry = Optional.ofNullable(retry).orElseGet(RetryPolicy.Exponential::new);
}

private Class<? extends ProtocolServer> parseProtocolServer() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ public RiemannOutputPlugin(
@JsonProperty("retry") RetryPolicy retry,
@JsonProperty("riemannTags") Set<String> riemannTags
) {
this.filter = Optional.ofNullable(filter).orElseGet(TrueFilter.supplier());
this.filter = Optional.ofNullable(filter).orElseGet(TrueFilter::new);
this.flushInterval = Optional.ofNullable(flushInterval).orElse(DEFAULT_FLUSH_INTERVAL);
this.protocol = Optional
.ofNullable(protocol)
.orElseGet(ProtocolFactory.defaultFor())
.protocol(DEFAULT_PROTOCOL, DEFAULT_PORT);
this.protocolClient = parseProtocolClient();
this.retry = Optional.ofNullable(retry).orElseGet(() -> new RetryPolicy.Exponential());
this.retry = Optional.ofNullable(retry).orElseGet(RetryPolicy.Exponential::new);
this.riemannTags = Optional.ofNullable(riemannTags).orElse(DEFAULT_TAGS);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public TemplateOutputPlugin(
.ofNullable(protocol)
.orElseGet(ProtocolFactory.defaultFor())
.protocol(DEFAULT_PROTOCOL, DEFAULT_PORT);
this.retry = Optional.ofNullable(retry).orElseGet(() -> new RetryPolicy.Exponential());
this.retry = Optional.ofNullable(retry).orElseGet(RetryPolicy.Exponential::new);
}

@Override
Expand Down

0 comments on commit 4262e58

Please sign in to comment.