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, Supplier<String> messageSupplier) 

Source Link

Document

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

Usage

From source file:org.jtalks.common.security.acl.JtalksMutableAcService.java

/**
 *{@inheritDoc}//from   ww  w  . j  a  v a2  s. co  m
 */
@Override
protected Long createOrRetrieveSidPrimaryKey(Sid sid, boolean allowCreate) {
    Assert.notNull(sid, "Sid required");
    Assert.isInstanceOf(UniversalSid.class, sid, "Unsupported sid implementation");

    String sidId = ((UniversalSid) sid).getSidId();
    boolean isPrinciple = ((UniversalSid) sid).isPrincipal();
    return createOrRetrieveSidPrimaryKey(sidId, isPrinciple, allowCreate);
}

From source file:org.openregistry.core.domain.jpa.JpaUrlImpl.java

/**
 * Sets the type for this Url./*w  w w.ja  va2s  . c om*/
 *
 * @param type the type of the URL.  Cannot be NULL.
 * @throws IllegalArgumentException if the provided Type is not of class JpaTypeImpl.
 */
public void setType(final Type type) throws IllegalArgumentException {
    Assert.isInstanceOf(JpaTypeImpl.class, type, "Must be of type JpaTypeImpl");

    this.type = (JpaTypeImpl) type;
}

From source file:org.springmodules.validation.valang.functions.FunctionTests.java

public void testLengthOfFunctionFail() {
    try {/*from  www. j a  v  a 2 s. co  m*/
        getLengthOfFunction(null).getResult(null);
        fail("LengthOfFunction should throw ValangException!");
    } catch (ValangException e) {
        Assert.isInstanceOf(NullPointerException.class, e.getCause(), "Cause is not NullPointerException!");
    }
}

From source file:net.shibboleth.idp.oidc.util.OIDCUtils.java

/**
 * Gets the http servlet request from the context.
 *
 * @param context the context//from   ww  w .ja v a2  s.  c o  m
 * @return the http servlet request
 */
public static HttpServletRequest getHttpServletRequest(final RequestContext context) {
    Assert.isInstanceOf(ServletExternalContext.class, context.getExternalContext(),
            "Cannot obtain HttpServletRequest from event of type: "
                    + context.getExternalContext().getClass().getName());

    return (HttpServletRequest) context.getExternalContext().getNativeRequest();
}

From source file:org.cleverbus.core.common.ws.ErrorCodeAwareSoapExceptionResolver.java

@Override
protected final boolean resolveExceptionInternal(MessageContext messageContext, Object endpoint, Exception ex) {
    Assert.isInstanceOf(SoapMessage.class, messageContext.getResponse(),
            "SimpleSoapExceptionResolver requires a SoapMessage");

    if (throttlingAsServerError && ex instanceof ThrottlingExceededException) {
        // no SOAP fault => server error
        return false;
    } else {//from ww  w  .j  a  v a  2 s  .  com
        SoapMessage response = (SoapMessage) messageContext.getResponse();
        String faultString = StringUtils.hasLength(ex.getMessage()) ? ex.getMessage() : ex.toString();
        SoapBody body = response.getSoapBody();
        SoapFault fault = body.addServerOrReceiverFault(faultString, getLocale());
        customizeFault(messageContext, endpoint, ex, fault);

        return true;
    }
}

From source file:org.jasig.springframework.web.portlet.context.ContribDispatcherPortlet.java

@Override
public void setEnvironment(Environment environment) {
    Assert.isInstanceOf(ConfigurablePortletEnvironment.class, environment,
            "ContribDispatcherPortlet environment must be of type " + "ConfigurablePortletEnvironment");

    super.setEnvironment(environment);
}

From source file:biz.c24.io.spring.oxm.C24Marshaller.java

public void marshal(Object graph, Result result) throws IOException, XmlMappingException {

    Assert.isInstanceOf(StreamResult.class, result, UNSUPPORTED_RESULT);
    Assert.isInstanceOf(ComplexDataObject.class, graph);

    XMLSink sink = getXmlSinkFrom((StreamResult) result);
    sink.writeObject((ComplexDataObject) graph);
}

From source file:it.reply.orchestrator.dto.deployment.CredentialsAwareSlaPlacementPolicy.java

/**
 * Set the password from an {@link AbstractPropertyValue}.
 * // ww  w.j  a  va 2 s . c  o  m
 * @param password
 *          the password
 */
public void setPassword(AbstractPropertyValue password) {
    Objects.requireNonNull(password, "password must not be null");
    Assert.isInstanceOf(ScalarPropertyValue.class, password, "password must be a scalar value");
    this.password = ((ScalarPropertyValue) password).getValue();
}

From source file:org.jtalks.common.security.acl.JtalksMutableAcService.java

/**
 * {@inheritDoc}/*from  w w w  .  j a v  a 2s.  co  m*/
 */
@Override
protected String getSidId(Sid sid) {
    Assert.notNull(sid, "Sid required");
    Assert.isInstanceOf(UniversalSid.class, sid, "Unsupported sid implementation");
    return ((UniversalSid) sid).getSidId();
}

From source file:org.lightadmin.core.web.support.DomainEntityLinks.java

@Override
public Link linkToSingleResource(Class<?> type, Object id) {
    if (id == null) {
        return linkFor(type).slash("new").withSelfRel();
    }//  w  w  w.  j a v a 2  s  .c om

    Assert.isInstanceOf(Serializable.class, id, "Id must be assignable to Serializable!");

    String mappedId = idConverters.getPluginFor(type, BackendIdConverter.DefaultIdConverter.INSTANCE)
            .toRequestId((Serializable) id, type);

    return linkFor(type).slash(mappedId).withSelfRel();
}