org.apache.olingo.server.api.prefer.Preferences Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of odata-v4-lib Show documentation
Show all versions of odata-v4-lib Show documentation
Repackaged OData V4 Olingo Library
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.server.api.prefer;
import java.net.URI;
import java.util.Collections;
import java.util.Map;
/**
* Provides access methods to the preferences set in Prefer HTTP request headers
* as described in RFC 7240.
* Preferences defined in the OData standard can be accessed with named methods.
*/
public interface Preferences {
/**
* Gets named preference. Names are case insensitive.
* @param name name of the preference
* @return {@link Preference} or null
if no such preference has been set
*/
public Preference getPreference(String name);
/** Whether the preference odata.allow-entityreferences
has been set. */
public boolean hasAllowEntityReferences();
/**
* Gets the value of the url
parameter of the preference
* odata.callback
or null
if not set or the URI is not valid.
* @return the callback URI
*/
public URI getCallback();
/** Whether the preference odata.continue-on-error
has been set. */
public boolean hasContinueOnError();
/**
* Gets the value of the preference odata.maxpagesize
* or null
if not set or an invalid value has been set.
* @return the page size for server-driven paging
*/
public Integer getMaxPageSize();
/** Whether the preference odata.track-changes
has been set. */
public boolean hasTrackChanges();
public enum Return {
REPRESENTATION, MINIMAL
}
/**
* Gets the value of the preference return
or null
if not set
* or the value is not valid.
*/
public Return getReturn();
/** Whether the preference respond-async
has been set. */
public boolean hasRespondAsync();
/**
* Gets the value of the preference wait
or null
if not set
* or the value is not valid.
* @return the number of seconds the client is prepared to wait for the service
* to process the request synchronously
*/
public Integer getWait();
/** Generic preference object. */
public class Preference {
private final String value;
private final Map parameters;
public Preference(final String value, final Map parameters) {
this.value = value;
this.parameters = parameters;
}
/**
* Gets the value of the preference. It may be null
if the preference has
* no value; this is not the same as the preference not set.
*/
public String getValue() {
return value;
}
/**
* Gets the parameters of the preference. The value of a parameter may be
* null
if the parameter has no value; this is not the same as
* the parameter not set. Parameter names are all lowercase.
* @return a map from parameter names to parameter values
*/
public Map getParameters() {
return parameters == null ?
Collections. emptyMap() :
Collections.unmodifiableMap(parameters);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy