Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Licensed 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 com.facebook.presto;
 
 
 
 import java.net.URI;
 import java.util.Map;
 
 import static com.google.common.base.MoreObjects.toStringHelper;
 import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkNotNull;
 import static java.util.Objects.requireNonNull;
 
 public final class Session
 {
     private final String user;
     @Nullable
     private final String source;
     private final String catalog;
     private final String schema;
     private final TimeZoneKey timeZoneKey;
     private final Locale locale;
     @Nullable
     private final String remoteUserAddress;
     @Nullable
     private final String userAgent;
     private final long startTime;
     private final Map<StringStringsystemProperties;
     private final Map<StringMap<StringString>> catalogProperties;
 
     @JsonCreator
     public Session(
             @JsonProperty("user"String user,
             @JsonProperty("source") @Nullable String source,
             @JsonProperty("catalog"String catalog,
             @JsonProperty("schema"String schema,
             @JsonProperty("timeZoneKey"TimeZoneKey timeZoneKey,
             @JsonProperty("locale"Locale locale,
             @JsonProperty("remoteUserAddress") @Nullable String remoteUserAddress,
             @JsonProperty("userAgent") @Nullable String userAgent,
             @JsonProperty("startTime"long startTime,
             @JsonProperty("systemProperties"Map<StringStringsystemProperties,
             @JsonProperty("catalogProperties"Map<StringMap<StringString>> catalogProperties)
     {
         this. = requireNonNull(user"user is null");
         this. = source;
         this. = requireNonNull(catalog"catalog is null");
         this. = requireNonNull(schema"schema is null");
         this. = requireNonNull(timeZoneKey"timeZoneKey is null");
         this. = requireNonNull(locale"locale is null");
         this. = remoteUserAddress;
         this. = userAgent;
         this. = startTime;
         this. = ImmutableMap.copyOf(systemProperties);
 
         ImmutableMap.Builder<StringMap<StringString>> catalogPropertiesBuilder = ImmutableMap.<StringMap<StringString>>builder();
         catalogProperties.entrySet().stream()
                 .map(entry -> Maps.immutableEntry(entry.getKey(), ImmutableMap.copyOf(entry.getValue())))
                 .forEach(catalogPropertiesBuilder::put);
         this. = catalogPropertiesBuilder.build();
     }
 
     @JsonProperty
     public String getUser()
     {
         return ;
     }
 
     @Nullable
     @JsonProperty
     public String getSource()
     {
         return ;
     }
    public String getCatalog()
    {
        return ;
    }
    public String getSchema()
    {
        return ;
    }
    public TimeZoneKey getTimeZoneKey()
    {
        return ;
    }
    public Locale getLocale()
    {
        return ;
    }
    @Nullable
    public String getRemoteUserAddress()
    {
        return ;
    }
    @Nullable
    public String getUserAgent()
    {
        return ;
    }
    public long getStartTime()
    {
        return ;
    }
    public Map<StringStringgetSystemProperties()
    {
        return ;
    }
    {
        return ;
    }
    public Session withSystemProperty(String keyString value)
    {
        checkNotNull(key"key is null");
        checkNotNull(value"value is null");
        Map<StringStringsystemProperties = new LinkedHashMap<>(this.);
        systemProperties.put(keyvalue);
        return new Session(
                ,
                ,
                ,
                ,
                ,
                ,
                ,
                ,
                ,
                systemProperties,
                );
    }
    public Session withCatalogProperty(String catalogString keyString value)
    {
        checkNotNull(catalog"catalog is null");
        checkNotNull(key"key is null");
        checkNotNull(value"value is null");
        Map<StringMap<StringString>> catalogProperties = new LinkedHashMap<>(this.);
        Map<StringStringproperties = catalogProperties.get(catalog);
        if (properties == null) {
            properties = new LinkedHashMap<>();
        }
        else {
            properties = new LinkedHashMap<>(properties);
        }
        properties.put(keyvalue);
        catalogProperties.put(catalogproperties);
        return new Session(
                ,
                ,
                catalog,
                ,
                ,
                ,
                ,
                ,
                ,
                ,
                catalogProperties);
    }
    {
        return new ConnectorSession(null);
    }
    public ConnectorSession toConnectorSession(String catalog)
    {
        return new ConnectorSession(.get(checkNotNull(catalog"catalog is null")));
    }
    public ClientSession toClientSession(URI serverboolean debug)
    {
        ImmutableMap.Builder<StringStringproperties = ImmutableMap.builder();
        properties.putAll();
        for (Entry<StringMap<StringString>> catalogProperties : this..entrySet()) {
            String catalog = catalogProperties.getKey();
            for (Entry<StringStringentry : catalogProperties.getValue().entrySet()) {
                properties.put(catalog + "." + entry.getKey(), entry.getValue());
            }
        }
        return new ClientSession(
                checkNotNull(server"server is null"),
                ,
                ,
                ,
                ,
                .getId(),
                ,
                properties.build(),
                debug);
    }
    @Override
    public String toString()
    {
        return toStringHelper(this)
                .add("user")
                .add("source")
                .add("catalog")
                .add("schema")
                .add("timeZoneKey")
                .add("locale")
                .add("remoteUserAddress")
                .add("userAgent")
                .add("startTime")
                .toString();
    }
    public static SessionBuilder builder()
    {
        return new SessionBuilder();
    }
    public static class SessionBuilder
    {
        private String user;
        private String source;
        private String catalog;
        private String schema;
        private TimeZoneKey timeZoneKey = TimeZoneKey.getTimeZoneKey(TimeZone.getDefault().getID());
        private Locale locale = Locale.getDefault();
        private String remoteUserAddress;
        private String userAgent;
        private long startTime = System.currentTimeMillis();
        private Map<StringStringsystemProperties = ImmutableMap.of();
        private final Map<StringMap<StringString>> catalogProperties = new HashMap<>();
        private SessionBuilder()
        {
        }
        public SessionBuilder setCatalog(String catalog)
        {
            this. = catalog;
            return this;
        }
        public SessionBuilder setLocale(Locale locale)
        {
            this. = locale;
            return this;
        }
        public SessionBuilder setRemoteUserAddress(String remoteUserAddress)
        {
            this. = remoteUserAddress;
            return this;
        }
        public SessionBuilder setSchema(String schema)
        {
            this. = schema;
            return this;
        }
        public SessionBuilder setSource(String source)
        {
            this. = source;
            return this;
        }
        public SessionBuilder setStartTime(long startTime)
        {
            this. = startTime;
            return this;
        }
        public SessionBuilder setTimeZoneKey(TimeZoneKey timeZoneKey)
        {
            this. = timeZoneKey;
            return this;
        }
        public SessionBuilder setUser(String user)
        {
            this. = user;
            return this;
        }
        public SessionBuilder setUserAgent(String userAgent)
        {
            this. = userAgent;
            return this;
        }

        
Sets the system properties for the session. The property names and values must only contain characters from US-ASCII and must not be for '='.
        public SessionBuilder setSystemProperties(Map<StringStringsystemProperties)
        {
            this. = ImmutableMap.copyOf(systemProperties);
            return this;
        }

        
Sets the properties for a catalog. The catalog name, property names, and values must only contain characters from US-ASCII and must not be for '='.
        public SessionBuilder setCatalogProperties(String catalogMap<StringStringproperties)
        {
            checkNotNull(catalog"catalog is null");
            checkArgument(!catalog.isEmpty(), "catalog is empty");
            .put(catalog, ImmutableMap.copyOf(properties));
            return this;
        }
        public Session build()
        {
        }
    }
New to GrepCode? Check out our FAQ X