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

com.sun.xml.ws.server.sei.ValueGetter Maven / Gradle / Ivy

There is a newer version: 4.0.2
Show newest version
/*
 * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Distribution License v. 1.0, which is available at
 * http://www.eclipse.org/org/documents/edl-v10.php.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

package com.sun.xml.ws.server.sei;

import com.sun.xml.ws.model.ParameterImpl;
import com.sun.xml.ws.api.model.Parameter;

import javax.jws.WebParam.Mode;
import javax.xml.ws.Holder;

/**
 * Gets a value from an object that represents a parameter passed
 * as a method argument.
 *
 * 

* This abstraction hides the handling of {@link Holder}. * *

* {@link ValueGetter} is a stateless behavior encapsulation. * * @author Kohsuke Kawaguchi */ public enum ValueGetter { /** * {@link ValueGetter} that works for {@link Mode#IN} parameter. * *

* Since it's the IN mode, the parameter is not a {@link Holder}, * therefore the parameter itself is a value. */ PLAIN() { public Object get(Object parameter) { return parameter; } }, /** * Creates {@link ValueGetter} that works for {@link Holder}, * which is {@link Mode#INOUT} or {@link Mode#OUT}. * *

* In those {@link Mode}s, the parameter is a {@link Holder}, * so the value to be sent is obtained by getting the value of the holder. */ HOLDER() { public Object get(Object parameter) { if(parameter==null) // the user is allowed to pass in null where a Holder is expected. return null; return ((Holder)parameter).value; } }; /** * Gets the value to be sent, from a parameter given as a method argument. */ public abstract Object get(Object parameter); /** * Returns a {@link ValueGetter} suitable for the given {@link Parameter}. */ public static ValueGetter get(ParameterImpl p) { // return value is always PLAIN if(p.getMode() == Mode.IN || p.getIndex() == -1) { return PLAIN; } else { return HOLDER; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy