All Downloads are FREE. Search and download functionalities are using the official Maven repository.

br.com.andrewribeiro.ribrest.exceptions.RibrestDefaultExceptionFactory Maven / Gradle / Ivy

Go to download

Ribrest Framework - A simple Java framework that truly improve your productivity when developing restful based webservices.

There is a newer version: 1.27.0
Show newest version
package br.com.andrewribeiro.ribrest.exceptions;

import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author Andrew Ribeiro
 */
public class RibrestDefaultExceptionFactory {

    private static final Map map = new HashMap<>();

    static {
        map.put(RibrestDefaultExceptionConstants.RESOURCE_DOESNT_IMPLEMENTS_ABSTRACT_METHODS, new StringBuilder("The created resource: ")
                .append("{{rn}}")
                .append(" is a IModel subclass but not implements its abstract methods.")
                .toString()
        );
        map.put(RibrestDefaultExceptionConstants.RESOURCE_IS_ABSTRACT, new StringBuilder("The created resource: ")
                .append("{{rn}}")
                .append(" can't be an abstract class.")
                .toString()
        );
        map.put(RibrestDefaultExceptionConstants.RESOURCE_IS_NOT_IMODEL_SUBCLASS, new StringBuilder("The created resource: ")
                .append("{{rn}}")
                .append(" does not implement IModel.\nRibrest can't operate in this class (yet).")
                .toString()
        );
        map.put(RibrestDefaultExceptionConstants.RESOURCE_ISNT_AN_ENTITY, new StringBuilder("The created resource: ")
                .append("{{rn}}")
                .append(" isn't an entity. Try to annotate it with @Entity.")
                .toString()
        );
    }

    public static RibrestDefaultException getRibrestDefaultException(String type, String rn) {

        String error = map.get(type);
        
        error = error.replace("{{rn}}", rn);
        
        return new RibrestDefaultException(error);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy