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

com.eclipsesource.tabris.tracking.internal.piwik.model.PiwikConfiguration Maven / Gradle / Ivy

The newest version!
/*******************************************************************************
 * Copyright (c) 2014 EclipseSource and others. All rights reserved. This
 * program and the accompanying materials are made available under the terms of
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
 * available at http://www.eclipse.org/legal/epl-v10.html Contributors:
 * EclipseSource - initial API and implementation
 ******************************************************************************/
package com.eclipsesource.tabris.tracking.internal.piwik.model;

import static com.eclipsesource.tabris.internal.Clauses.when;
import static com.eclipsesource.tabris.internal.Clauses.whenNull;
import static com.eclipsesource.tabris.tracking.internal.piwik.request.RequestKeyProvider.getRequestKey;
import static com.eclipsesource.tabris.tracking.internal.piwik.request.RequestKeys.API_VERSION;
import static com.eclipsesource.tabris.tracking.internal.piwik.request.RequestKeys.SITE_ID;

import java.util.HashMap;
import java.util.Map;

import com.eclipsesource.tabris.tracking.internal.Requestable;


@SuppressWarnings("restriction")
public class PiwikConfiguration implements Requestable {

  private final Map parameter;

  public PiwikConfiguration( String apiVersion, int siteId ) {
    whenNull( apiVersion ).throwIllegalArgument( "ApiVersion must not be null." );
    when( apiVersion.isEmpty() ).throwIllegalArgument( "ApiVersion must not be empty." );
    when( siteId <= 0 ).throwIllegalArgument( "SiteId must be > 0 but was " + siteId );
    parameter = new HashMap();
    addParameter( getRequestKey( API_VERSION ), apiVersion );
    addParameter( getRequestKey( SITE_ID ), Integer.valueOf( siteId ) );
  }

  protected void addParameter( String key, Object value ) {
    parameter.put( key, value );
  }

  @Override
  public Map getParameter() {
    return parameter;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy