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

org.tiogasolutions.app.thymeleaf.ClassPathResourceResolver Maven / Gradle / Ivy

There is a newer version: 1.0.1
Show newest version
package org.tiogasolutions.app.thymeleaf;

import org.thymeleaf.TemplateProcessingParameters;
import org.thymeleaf.resourceresolver.IResourceResolver;
import org.tiogasolutions.dev.common.exceptions.ExceptionUtils;

import java.io.InputStream;

public class ClassPathResourceResolver implements IResourceResolver {

  public ClassPathResourceResolver() {
  }

  @Override
  public String getName() {
    return "CLASSPATH";
  }

  @Override
  public InputStream getResourceAsStream(final TemplateProcessingParameters templateProcessingParameters, final String resourceName) {
    ExceptionUtils.assertNotNull(resourceName, "resourceName");
    InputStream is = getClass().getResourceAsStream(resourceName);
    if (is != null) return is;

    String msg = String.format("The resource \"%s\" was not found.", resourceName);
    throw new IllegalArgumentException(msg);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy