Example usage for org.springframework.util Assert isInstanceOf

List of usage examples for org.springframework.util Assert isInstanceOf

Introduction

In this page you can find the example usage for org.springframework.util Assert isInstanceOf.

Prototype

public static void isInstanceOf(Class<?> type, @Nullable Object obj) 

Source Link

Document

Assert that the provided object is an instance of the provided class.

Usage

From source file:net.sf.gazpachoquest.questionnaire.resolver.QuestionByQuestionRelevanceAwareResolver.java

@Override
protected QuestionBreadcrumb findPreviousBreadcrumb(QuestionnaireDefinition questionnaireDefinition,
        Questionnaire questionnaire, QuestionBreadcrumb lastBreadcrumb, Integer lastBreadcrumbPosition) {
    Assert.notNull(lastBreadcrumbPosition,
            "Questionnaire not started for the given questionnaireId = " + lastBreadcrumbPosition);

    if (lastBreadcrumbPosition == INITIAL_POSITION) {
        return null;
    }//w ww  . ja  v a2s .co m
    Breadcrumb breadcrumb = breadcrumbService.findByQuestionnaireIdAndPosition(questionnaire.getId(),
            lastBreadcrumbPosition - 1);
    Assert.isInstanceOf(QuestionBreadcrumb.class, breadcrumb);
    return (QuestionBreadcrumb) breadcrumb;
}

From source file:your.microservice.core.util.YourServletUriComponentsBuilder.java

/**
 * Obtain the request through {@link RequestContextHolder}.
 * @return the active servlet request/* w  ww .j a va2 s. com*/
 */
protected static HttpServletRequest getCurrentRequest() {
    RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
    Assert.state(requestAttributes != null, "Could not find current request via RequestContextHolder");
    Assert.isInstanceOf(ServletRequestAttributes.class, requestAttributes);
    HttpServletRequest servletRequest = ((ServletRequestAttributes) requestAttributes).getRequest();
    Assert.state(servletRequest != null, "Could not find current HttpServletRequest");
    return servletRequest;
}

From source file:org.LexGrid.LexBIG.caCore.test.rest.RESTTest.java

public void testRESTXMLInvalidURLParenthesis() throws Exception {
    try {/*from   w  w  w . ja v  a2  s. co m*/
        callRestfulService(
                "GetXML?query=org.LexGrid.concepts.Entity&org.LexGrid.concepts.Entity[@_entityCode=29506000][@_entityCodeNamespace=SNOMED%20Clinical%20Terms]]");
    } catch (Exception e) {
        Assert.isInstanceOf(IOException.class, e);
        assertTrue(e.getMessage().contains("HTTP response code: 400"));
        return;
    }
    fail();
}

From source file:org.openregistry.core.domain.jpa.sor.JpaSorAddressImpl.java

public void setCountry(final Country country) {
    Assert.isInstanceOf(JpaCountryImpl.class, country);
    this.country = (JpaCountryImpl) country;
}

From source file:com.github.springtestdbunit.DbUnitTestExecutionListener.java

private void prepareDatabaseConnection(TestContext testContext, String databaseConnectionBeanName)
        throws Exception {
    Object databaseConnection = testContext.getApplicationContext().getBean(databaseConnectionBeanName);
    if (databaseConnection instanceof DataSource) {
        databaseConnection = DatabaseDataSourceConnectionFactoryBean
                .newConnection((DataSource) databaseConnection);
    }// w w  w.  jav a  2 s.  com
    Assert.isInstanceOf(IDatabaseConnection.class, databaseConnection);
    testContext.setAttribute(CONNECTION_ATTRIBUTE, databaseConnection);
}

From source file:org.openregistry.core.domain.jpa.sor.JpaSorRoleImpl.java

public JpaSorRoleImpl(final Type affiliationType, final SorPerson sorPerson) {
    Assert.isInstanceOf(JpaTypeImpl.class, affiliationType);
    Assert.isInstanceOf(JpaSorPersonImpl.class, sorPerson);
    this.affiliationType = (JpaTypeImpl) affiliationType;
    this.person = (JpaSorPersonImpl) sorPerson;
}

From source file:com.yeahmobi.yunit.DbUnitTestExecutionListener.java

private void prepareDatabaseConnection(DbUnitTestContextAdapter testContext, String databaseConnectionBeanName)
        throws Exception {
    Object databaseConnection = testContext.getApplicationContext().getBean(databaseConnectionBeanName);
    if (databaseConnection instanceof DataSource) {
        databaseConnection = DatabaseDataSourceConnectionFactoryBean
                .newConnection((DataSource) databaseConnection);
    }/*from   w  w  w  .ja v  a 2 s  . c  om*/
    Assert.isInstanceOf(IDatabaseConnection.class, databaseConnection);
    testContext.setAttribute(CONNECTION_ATTRIBUTE, databaseConnection);
}

From source file:org.openregistry.core.domain.jpa.sor.JpaSorRoleImpl.java

public void expire(final Type terminationReason, final Date expirationDate) {
    Assert.isInstanceOf(JpaTypeImpl.class, terminationReason);
    this.end = expirationDate;
    this.terminationReason = (JpaTypeImpl) terminationReason;
}

From source file:org.openregistry.core.domain.jpa.sor.JpaSorPersonImpl.java

public SorName addName(Type type) {
    Assert.isInstanceOf(JpaTypeImpl.class, type);
    final JpaSorNameImpl jpaSorName = new JpaSorNameImpl(this);
    jpaSorName.setType(type);/* ww  w.  j  a v a 2s . co  m*/
    this.names.add(jpaSorName);
    return jpaSorName;
}

From source file:com.alibaba.dubbo.config.spring.context.annotation.DubboConfigBindingRegistrar.java

@Override
public void setEnvironment(Environment environment) {

    Assert.isInstanceOf(ConfigurableEnvironment.class, environment);

    this.environment = (ConfigurableEnvironment) environment;

}