Skip to content

Commit

Permalink
Removed Serializabe functions/consumers. We don't need to worry about
Browse files Browse the repository at this point in the history
serialization
  • Loading branch information
bitstorm committed Dec 24, 2016
1 parent 9f89378 commit cfa34e6
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
*/
package org.wicketstuff.rest.lambda.mounter;

import java.util.function.Consumer;
import java.util.function.Function;

import org.apache.wicket.core.request.mapper.ResourceMapper;
import org.apache.wicket.protocol.http.WebApplication;
import org.apache.wicket.request.resource.IResource;
import org.apache.wicket.request.resource.ResourceReference;
import org.danekja.java.util.function.serializable.SerializableConsumer;
import org.danekja.java.util.function.serializable.SerializableFunction;
import org.wicketstuff.rest.lambda.request.mapper.RestResourceMapper;
import org.wicketstuff.rest.lambda.resource.SimpleLambdaResource;
import org.wicketstuff.rest.lambda.resource.TextOutputLambdaResource;
Expand Down Expand Up @@ -62,8 +63,8 @@ public LambdaRestMounter(WebApplication application)
* @param respondFunction the respond function
* @param outputFunction the output function
*/
public void post(final String path, final SerializableFunction<AttributesWrapper, Object> respondFunction,
final SerializableFunction<Object, String> outputFunction)
public void post(final String path, final Function<AttributesWrapper, Object> respondFunction,
final Function<Object, String> outputFunction)
{
mountRestResource(HttpMethod.POST, path, respondFunction, outputFunction);
}
Expand All @@ -75,7 +76,7 @@ public void post(final String path, final SerializableFunction<AttributesWrapper
* @param path the mounting path
* @param respondConsumer the respond consumer
*/
public void post(final String path, final SerializableConsumer<AttributesWrapper> respondConsumer)
public void post(final String path, final Consumer<AttributesWrapper> respondConsumer)
{
mountRestResource(HttpMethod.POST, path, respondConsumer);
}
Expand All @@ -88,8 +89,8 @@ public void post(final String path, final SerializableConsumer<AttributesWrapper
* @param respondFunction the respond function
* @param outputFunction the output function
*/
public void get(final String path, final SerializableFunction<AttributesWrapper, Object> respondFunction,
final SerializableFunction<Object, String> outputFunction)
public void get(final String path, final Function<AttributesWrapper, Object> respondFunction,
final Function<Object, String> outputFunction)
{
mountRestResource(HttpMethod.GET, path, respondFunction, outputFunction);
}
Expand All @@ -101,7 +102,7 @@ public void get(final String path, final SerializableFunction<AttributesWrapper,
* @param path the mounting path
* @param respondConsumer the respond consumer
*/
public void get(final String path, final SerializableConsumer<AttributesWrapper> respondConsumer)
public void get(final String path, final Consumer<AttributesWrapper> respondConsumer)
{
mountRestResource(HttpMethod.GET, path, respondConsumer);
}
Expand All @@ -113,7 +114,7 @@ public void get(final String path, final SerializableConsumer<AttributesWrapper>
* @param path the mounting path
* @param respondConsumer the respond consumer
*/
public void put(final String path, final SerializableConsumer<AttributesWrapper> respondConsumer)
public void put(final String path, final Consumer<AttributesWrapper> respondConsumer)
{
mountRestResource(HttpMethod.PUT, path, respondConsumer);
}
Expand All @@ -126,8 +127,8 @@ public void put(final String path, final SerializableConsumer<AttributesWrapper>
* @param respondFunction the respond function
* @param outputFunction the output function
*/
public void put(final String path, final SerializableFunction<AttributesWrapper, Object> respondFunction,
final SerializableFunction<Object, String> outputFunction)
public void put(final String path, final Function<AttributesWrapper, Object> respondFunction,
final Function<Object, String> outputFunction)
{
mountRestResource(HttpMethod.PUT, path, respondFunction, outputFunction);
}
Expand All @@ -139,7 +140,7 @@ public void put(final String path, final SerializableFunction<AttributesWrapper,
* @param path the mounting path
* @param respondConsumer the respond consumer
*/
public void delete(final String path, final SerializableConsumer<AttributesWrapper> respondConsumer)
public void delete(final String path, final Consumer<AttributesWrapper> respondConsumer)
{
mountRestResource(HttpMethod.DELETE, path, respondConsumer);
}
Expand All @@ -152,8 +153,8 @@ public void delete(final String path, final SerializableConsumer<AttributesWrapp
* @param respondFunction the respond function
* @param outputFunction the output function
*/
public void delete(final String path, final SerializableFunction<AttributesWrapper, Object> respondFunction,
final SerializableFunction<Object, String> outputFunction)
public void delete(final String path, final Function<AttributesWrapper, Object> respondFunction,
final Function<Object, String> outputFunction)
{
mountRestResource(HttpMethod.DELETE, path, respondFunction, outputFunction);
}
Expand All @@ -165,7 +166,7 @@ public void delete(final String path, final SerializableFunction<AttributesWrapp
* @param path the mounting path
* @param respondConsumer the respond consumer
*/
public void options(final String path, final SerializableConsumer<AttributesWrapper> respondConsumer)
public void options(final String path, final Consumer<AttributesWrapper> respondConsumer)
{
mountRestResource(HttpMethod.OPTIONS, path, respondConsumer);
}
Expand All @@ -178,8 +179,8 @@ public void options(final String path, final SerializableConsumer<AttributesWrap
* @param respondFunction the respond function
* @param outputFunction the output function
*/
public void options(final String path, final SerializableFunction<AttributesWrapper, Object> respondFunction,
final SerializableFunction<Object, String> outputFunction)
public void options(final String path, final Function<AttributesWrapper, Object> respondFunction,
final Function<Object, String> outputFunction)
{
mountRestResource(HttpMethod.OPTIONS, path, respondFunction, outputFunction);
}
Expand All @@ -191,7 +192,7 @@ public void options(final String path, final SerializableFunction<AttributesWrap
* @param path the mounting path
* @param respondConsumer the respond consumer
*/
public void patch(final String path, final SerializableConsumer<AttributesWrapper> respondConsumer)
public void patch(final String path, final Consumer<AttributesWrapper> respondConsumer)
{
mountRestResource(HttpMethod.PATCH, path, respondConsumer);
}
Expand All @@ -204,8 +205,8 @@ public void patch(final String path, final SerializableConsumer<AttributesWrappe
* @param respondFunction the respond function
* @param outputFunction the output function
*/
public void patch(final String path, final SerializableFunction<AttributesWrapper, Object> respondFunction,
final SerializableFunction<Object, String> outputFunction)
public void patch(final String path, final Function<AttributesWrapper, Object> respondFunction,
final Function<Object, String> outputFunction)
{
mountRestResource(HttpMethod.PATCH, path, respondFunction, outputFunction);
}
Expand All @@ -217,7 +218,7 @@ public void patch(final String path, final SerializableFunction<AttributesWrappe
* @param path the mounting path
* @param respondConsumer the respond consumer
*/
public void head(final String path, final SerializableConsumer<AttributesWrapper> respondConsumer)
public void head(final String path, final Consumer<AttributesWrapper> respondConsumer)
{
mountRestResource(HttpMethod.HEAD, path, respondConsumer);
}
Expand All @@ -230,8 +231,8 @@ public void head(final String path, final SerializableConsumer<AttributesWrapper
* @param respondFunction the respond function
* @param outputFunction the output function
*/
public void head(final String path, final SerializableFunction<AttributesWrapper, Object> respondFunction,
final SerializableFunction<Object, String> outputFunction)
public void head(final String path, final Function<AttributesWrapper, Object> respondFunction,
final Function<Object, String> outputFunction)
{
mountRestResource(HttpMethod.HEAD, path, respondFunction, outputFunction);
}
Expand All @@ -243,7 +244,7 @@ public void head(final String path, final SerializableFunction<AttributesWrapper
* @param path the mounting path
* @param respondConsumer the respond consumer
*/
public void trace(final String path, final SerializableConsumer<AttributesWrapper> respondConsumer)
public void trace(final String path, final Consumer<AttributesWrapper> respondConsumer)
{
mountRestResource(HttpMethod.TRACE, path, respondConsumer);
}
Expand All @@ -256,8 +257,8 @@ public void trace(final String path, final SerializableConsumer<AttributesWrappe
* @param respondFunction the respond function
* @param outputFunction the output function
*/
public void trace(final String path, final SerializableFunction<AttributesWrapper, Object> respondFunction,
final SerializableFunction<Object, String> outputFunction)
public void trace(final String path, final Function<AttributesWrapper, Object> respondFunction,
final Function<Object, String> outputFunction)
{
mountRestResource(HttpMethod.TRACE, path, respondFunction, outputFunction);
}
Expand All @@ -272,8 +273,8 @@ public void trace(final String path, final SerializableFunction<AttributesWrappe
* @return the resource mapper
*/
public ResourceMapper mountRestResource(final HttpMethod httpMethod, final String path,
final SerializableFunction<AttributesWrapper, Object> respondFunction,
final SerializableFunction<Object, String> outputFunction)
final Function<AttributesWrapper, Object> respondFunction,
final Function<Object, String> outputFunction)
{
TextOutputLambdaResource resource = new TextOutputLambdaResource(respondFunction, outputFunction);
return mountRestResource(httpMethod, path, resource);
Expand All @@ -288,7 +289,7 @@ public ResourceMapper mountRestResource(final HttpMethod httpMethod, final Strin
* @return the resource mapper
*/
public ResourceMapper mountRestResource(final HttpMethod httpMethod, final String path,
final SerializableConsumer<AttributesWrapper> respondConsumer)
final Consumer<AttributesWrapper> respondConsumer)
{
SimpleLambdaResource resource = new SimpleLambdaResource(respondConsumer);
return mountRestResource(httpMethod, path, resource);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
*/
package org.wicketstuff.rest.lambda.resource;

import java.util.function.Consumer;

import org.apache.wicket.request.resource.IResource;
import org.danekja.java.util.function.serializable.SerializableConsumer;
import org.wicketstuff.rest.utils.wicket.AttributesWrapper;

/**
Expand All @@ -34,7 +35,7 @@ public class SimpleLambdaResource implements IResource {
*/
private static final long serialVersionUID = -4514142899864801685L;

protected final SerializableConsumer<AttributesWrapper> respondConsumer;
protected final Consumer<AttributesWrapper> respondConsumer;

/**
* Build a new resource providing the {@link java.util.function.Consumer}
Expand All @@ -43,7 +44,7 @@ public class SimpleLambdaResource implements IResource {
* @param respondConsumer
* the cosnumer.
*/
public SimpleLambdaResource(SerializableConsumer<AttributesWrapper> respondConsumer)
public SimpleLambdaResource(Consumer<AttributesWrapper> respondConsumer)
{
this.respondConsumer = respondConsumer;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@

import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.Function;

import org.apache.wicket.request.http.WebResponse;
import org.apache.wicket.request.resource.IResource;
import org.danekja.java.util.function.serializable.SerializableFunction;
import org.wicketstuff.rest.utils.wicket.AttributesWrapper;

/**
Expand All @@ -41,9 +41,9 @@ public class TextOutputLambdaResource implements IResource
*/
private static final long serialVersionUID = 2761454069675861246L;

final private SerializableFunction<AttributesWrapper, Object> respondFunction;
final private Function<AttributesWrapper, Object> respondFunction;

final private SerializableFunction<Object, String> outputTextFunction;
final private Function<Object, String> outputTextFunction;

/**
* Build a new resource using the two provided functions.
Expand All @@ -53,8 +53,8 @@ public class TextOutputLambdaResource implements IResource
* @param outputTextFunction
* the function used to convert the respond result to text.
*/
public TextOutputLambdaResource(SerializableFunction<AttributesWrapper, Object> respondFunction,
SerializableFunction<Object, String> outputTextFunction)
public TextOutputLambdaResource(Function<AttributesWrapper, Object> respondFunction,
Function<Object, String> outputTextFunction)
{
this.respondFunction = respondFunction;
this.outputTextFunction = outputTextFunction;
Expand Down

0 comments on commit cfa34e6

Please sign in to comment.