package org.analogweb.core;


import org.analogweb.Direction;
import org.analogweb.DirectionResolver;
import org.analogweb.InvocationMetadata;
import org.analogweb.RequestContext;
import org.analogweb.core.direction.HttpStatus;
import org.analogweb.core.direction.Text;
import org.analogweb.exception.UnresolvableResultException;

/**
 * @author snowgoose
 */
public class DefaultDirectionResolver implements DirectionResolver {

    @Override
    public Direction resolve(Object invocationResult, InvocationMetadata metadata,
            RequestContext context) {
        Class<?> type = invocationResult.getClass();
        if(type.equals(Integer.TYPE) || Integer.class.isAssignableFrom(type)){
            return HttpStatus.valueOf((Integer)invocationResult);
        }
        if (String.class.isAssignableFrom(type)) {
            return Text.with((String) invocationResult);
        }
        if (Direction.class.isAssignableFrom(type)) {
            return (Direction) invocationResult;
        } else {
            throw new UnresolvableResultException(invocationResult);
        }
    }

}

@@ -22,17 +22,16 @@
 .core;%0A%0A
-%0A
 import o
@@ -650,21 +650,20 @@
 YPE) %7C%7C 
-Integ
+Numb
 er.class
@@ -711,33 +711,31 @@
 urn 
-HttpStatus.valueOf((Integ
+numberToDirection((Numb
 er)i
@@ -836,17 +836,25 @@
 urn 
-Text.with
+stringToDirection
 ((St
@@ -1092,12 +1092,222 @@
  %7D%0A    %7D
+%0A    %0A    protected Direction numberToDirection(Number num)%7B%0A        return HttpStatus.valueOf(num.intValue());%0A    %7D%0A%0A    protected Direction stringToDirection(String str)%7B%0A        return Text.with(str);%0A    %7D
 %0A%0A%7D%0A

Improve method overridable