text:
package scuff.unsafe

import scuff.Numbers.unsigned
import java.util.Arrays

/**
 * Unsafe `CharSequence` implementation, taking an
 * existing `Array[Byte]` without copying and without
 * bounds checking and with the assumption that all chars
 * falls within the ASCII range of 0-255.
 * This also  assumes that the user will only use indexing
 * between `offset` and `length`.
 */
final class AsciiCharSeq(ascii: Array[Byte], offset: Int = 0, len: Int = -1) extends CharSequence {
  def charAt(idx: Int) = unsigned(ascii(offset + idx)).asInstanceOf[Char]
  def length() = if (len == -1) ascii.length - offset else len
  def subSequence(strIdx: Int, endIdx: Int) = new AsciiCharSeq(ascii, offset + strIdx, endIdx - strIdx)
  override def toString() = new String(ascii, offset, length, AsciiCharSeq.ASCII)
  def getBytes(): Array[Byte] =
    if (offset == 0 && length == ascii.length) ascii
    else Arrays.copyOfRange(ascii, offset, length + offset)
}

private object AsciiCharSeq {
  val ASCII = java.nio.charset.Charset.forName("US-ASCII")
}


text:
{% if include_jquery %}
<script type="text/javascript" src="{{ JQUERY_URL }}"></script>
{% endif %}
<script type="text/javascript" src="{{ MARKITUP_JS }}"></script>
<script type="text/javascript" src="{{ MARKITUP_SET }}/set.js"></script>

redpajama_set_name: RedPajamaGithub


text:
package pl.pronux.sokker.actions;

import java.io.IOException;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import pl.pronux.sokker.data.sql.SQLQuery;
import pl.pronux.sokker.data.sql.SQLSession;
import pl.pronux.sokker.data.sql.dao.DatabaseConfigurationDao;
import pl.pronux.sokker.data.sql.dao.JuniorsDao;
import pl.pronux.sokker.data.sql.dao.PlayersDao;
import pl.pronux.sokker.data.sql.dao.TeamsDao;
import pl.pronux.sokker.model.ClubArenaName;
import pl.pronux.sokker.model.ClubName;
import pl.pronux.sokker.model.Date;
import pl.pronux.sokker.model.DbProperties;
import pl.pronux.sokker.model.JuniorSkills;
import pl.pronux.sokker.model.PlayerSkills;
import pl.pronux.sokker.model.Rank;
import pl.pronux.sokker.model.Training;
import pl.pronux.sokker.resources.Messages;

public final class ConfigurationManager {

	private static ConfigurationManager instance = new ConfigurationManager();

	private ConfigurationManager() {
	}

	public static ConfigurationManager getInstance() {
		return instance;
	}

	public void updateDbRepairCoaches(boolean b) throws SQLException {
		DatabaseConfigurationDao dbConfDao = new DatabaseConfigurationDao(SQLSession.getConnection());
		dbConfDao.setDbRepair(b);
	}

	public void updateDbCountry(boolean b) throws SQLException {
		DatabaseConfigurationDao dbConfDao = new DatabaseConfigurationDao(SQLSession.getConnection());
		dbConfDao.setDbCountry(b);
	}

	public void updateDbDate(Date date) throws SQLException {
		DatabaseConfigurationDao dbConfDao = new DatabaseConfigurationDao(SQLSession.getConnection());
		dbConfDao.setDbDate(date);
	}

	public void updateDbUpdate(boolean b) throws SQLException {
		DatabaseConfigurationDao dbConfDao = new DatabaseConfigurationDao(SQLSession.getConnection());
		dbConfDao.setDbUpdate(b);
	}

	public void updateDbVersion(int version) throws SQLException {
		DatabaseConfigurationDao dbConfDao = new DatabaseConfigurationDao(SQLSession.getConnection());
		dbConfDao.setDBVersion(version);
	}

	public void updateDbRepairJuniorsAge(boolean b) throws SQLException {
		DatabaseConfigurationDao dbConfDao = new DatabaseConfigurationDao(SQLSession.getConnection());
		dbConfDao.setDbRepairJuniorsAge(b);
	}

	public DbProperties getDbProperties() throws SQLException {
		DatabaseConfigurationDao dbConfDao = new DatabaseConfigurationDao(SQLSession.getConnection());
		return dbConfDao.getDbProperties();
	}

	public Date getMaxDate() throws SQLException {
		DatabaseConfigurationDao dbConfDao = new DatabaseConfigurationDao(SQLSession.getConnection());
		return dbConfDao.getMaxDate();
	}

	public void updateDbStructure(int dbVersion) throws SQLException, ClassNotFoundException, IOException {
		try {
			SQLSession.beginTransaction();
			DatabaseConfigurationDao databaseConfigurationDao = new DatabaseConfigurationDao(SQLSession.getConnection());
			while (databaseConfigurationDao.checkDBVersion() < dbVersion) {
				SQLQuery.updateDB(SQLSession.getConnection(), databaseConfigurationDao.checkDBVersion() + 1);
			}
			SQLSession.commit();
		} catch (SQLException e) {
			SQLSession.rollback();
			throw e;
		} finally {
			SQLSession.endTransaction();
		}
	}

	public void updateDbTeamId(int teamId) throws SQLException {
		DatabaseConfigurationDao dbConfDao = new DatabaseConfigurationDao(SQLSession.getConnection());
		dbConfDao.setDBTeamId(teamId);
	}

	public int getTeamId() throws SQLException {
		DatabaseConfigurationDao dbConfDao = new DatabaseConfigurationDao(SQLSession.getConnection());
		return dbConfDao.getTeamId();
	}

	public void setJuniorMinimumPop(double pop) throws SQLException {
		try {
			SQLSession.connect();
			new DatabaseConfigurationDao(SQLSession.getConnection()).setJuniorMinimumPop(pop);
		} finally {
			SQLSession.close();
		}
	}

	public void updateScanCounter(int scanCounter) throws SQLException {
		DatabaseConfigurationDao dbConfDao = new DatabaseConfigurationDao(SQLSession.getConnection());
		dbConfDao.updateScanCounter(scanCounter);
	}

	public double getJuniorMinimumPop() throws SQLException {
		DatabaseConfigurationDao dbConfDao = new DatabaseConfigurationDao(SQLSession.getConnection());
		return dbConfDao.getJuniorMinimumPop();
	}

	public void repairDatabase() throws SQLException {
		int teamId = getTeamId();
		TeamsDao teamsDao = new TeamsDao(SQLSession.getConnection());
		PlayersDao playersDao = new PlayersDao(SQLSession.getConnection());
		JuniorsDao juniorsDao = new JuniorsDao(SQLSession.getConnection());

		List<ClubArenaName> clubArenaNameList = teamsDao.getClubArenaName(teamId);
		List<ClubName> clubNameList = teamsDao.getClubName(teamId);
		List<Rank> rankList = teamsDao.getRank(teamId);
		Rank previousRank = null;
		for (Rank rank : rankList) {
			if (previousRank == null) {
				previousRank = rank;
			} else {
				if (rank.getRank() == previousRank.getRank()) {
					teamsDao.deleteRank(teamId, rank);
				} else {
					previousRank = rank;
				}
			}
		}
		ClubArenaName previousClubArenaName = null;
		for (ClubArenaName clubArenaName : clubArenaNameList) {
			if (previousClubArenaName == null) {
				previousClubArenaName = clubArenaName;
			} else {
				if (clubArenaName.getArenaName().equals(previousClubArenaName.getArenaName())) {
					teamsDao.deleteClubArenaName(teamId, clubArenaName);
				} else {
					previousClubArenaName = clubArenaName;
				}
			}
		}
		ClubName previousClubName = null;
		for (ClubName clubName : clubNameList) {
			if (previousClubName == null) {
				previousClubName = clubName;
			} else {
				if (clubName.getName().equals(previousClubName.getName())) {
					teamsDao.deleteClubName(teamId, clubName);
				} else {
					previousClubName = clubName;
				}
			}
		}

		List<Training> trainings = teamsDao.getTrainings();
		Map<Integer, Training> trainingsMap = new HashMap<Integer, Training>();
		for (Training training : trainings) {
			trainingsMap.put(training.getDate().getSokkerDate().getTrainingWeek(), training);
		}

		List<PlayerSkills> skills = playersDao.getPlayerSkillsWithoutTrainingId();
		for (PlayerSkills playerSkills : skills) {
			Training training = trainingsMap.get(playerSkills.getDate().getSokkerDate().getTrainingWeek());
			if (training != null) {
				playerSkills.setTrainingId(training.getId());
			} else {
				Training trainingDefault = new Training();
				trainingDefault.setFormation(Training.FORMATION_ALL);
				trainingDefault.setType(Training.TYPE_UNKNOWN);
				trainingDefault.setDate(playerSkills.getDate());

				teamsDao.addTraining(trainingDefault);
				int trainingId = teamsDao.getTrainingId(trainingDefault);
				if (trainingId > -1) {
					trainingDefault.setId(trainingId);
					playerSkills.setTrainingId(trainingId);
					trainingsMap.put(trainingDefault.getDate().getSokkerDate().getTrainingWeek(), trainingDefault);
				} else {
					throw new SQLException(Messages.getString("DatabaseConfiguration.exception.repairing.players"));
				}

			}
			playersDao.updatePlayerTrainingId(playerSkills);
		}

		List<JuniorSkills> juniorsSkills = juniorsDao.getJuniorSkillsWithoutTrainingId();
		for (JuniorSkills juniorSkills : juniorsSkills) {
			Training training = trainingsMap.get(juniorSkills.getDate().getSokkerDate().getTrainingWeek());
			if (training != null) {
				juniorSkills.setTraining(training);
			} else {
				Training trainingDefault = new Training();
				trainingDefault.setFormation(Training.FORMATION_ALL);
				trainingDefault.setType(Training.TYPE_UNKNOWN);
				trainingDefault.setDate(juniorSkills.getDate());

				teamsDao.addTraining(trainingDefault);
				int trainingId = teamsDao.getTrainingId(trainingDefault);
				if (trainingId > -1) {
					trainingDefault.setId(trainingId);
					juniorSkills.setTraining(trainingDefault);
					trainingsMap.put(trainingDefault.getDate().getSokkerDate().getTrainingWeek(), trainingDefault);
				} else {
					throw new SQLException(Messages.getString("DatabaseConfiguration.exception.repairing.juniors"));
				}

			}
			juniorsDao.updateJuniorTrainingId(juniorSkills);
		}

	}

}


text:
import mongoose from 'mongoose';
import Course from './course.model';
import Comment from './comment.model';
import Answer from './answer.model';
import thread from './thread.model';

import Institution from './institution.model';
// Import library to hash passwords
import bcrypt from 'bcrypt-nodejs';
import jwt from 'jsonwebtoken';
var deepPopulate = require('mongoose-deep-populate')(mongoose);

// Define the schema for the showcase item
let userSchema = mongoose.Schema({
  username : {
    type: String
  },
  image : {
    type: String,
    default : 'default.jpg'
  },
  local : {

    username : { type : String, unique : true },

    password : String,

    email : { type : String, unique : true }
  },
  rated: {
    id : {
      type : String
    },
    value : {
      type : Number
    }
  },
  profile : {
    firstname : { type : String },
    lastname : { type : String },
    fullname : { type : String },
    bio : { type : String },
    email : { type : String },
    url : { type : String },
    company : { type : String },
    location : { type : String }
  },
  role : { type : String , default: 'user'},
  courses : [{ type : mongoose.Schema.Types.ObjectId, ref: 'Course'}],
  institution : { type : String },
  activity : {
    comments : [{ type : mongoose.Schema.Types.ObjectId, ref: 'Comment'}],
    answers : [{ type : mongoose.Schema.Types.ObjectId, ref: 'Answer'}],
    threads : [{ type : mongoose.Schema.Types.ObjectId, ref: 'thread'}]
  },
  bookmarked : [
    { type : mongoose.Schema.Types.ObjectId, ref: 'thread'}
  ],
  unread : {
    threads : [thread.schema]
  },
  date : {
    type : Date,
    default : Date.now
  },
  loggedOut : { type: Date },
  events : {
    title : {
      type : String
    },
    start : {
      type : Date
    },
    end : {
      type: Date
    },
    color : {
      type: String
    },
    draggable : {
      type : Boolean,
      default: true
    },
    resizable : {
      beforeStart : {
        type: Boolean,
        default : true
      },
      afterEnd: {
        type: Boolean,
        default : true
      }
    }
  }
});

// ## Methods
userSchema.plugin(deepPopulate, {})
// ### Generate a hash
userSchema.methods.generateHash = function(password) {

  return bcrypt.hashSync(password, bcrypt.genSaltSync(8), null);
};

// ### Check if password is valid
userSchema.methods.validPassword = function(password) {

  return bcrypt.compareSync(password, this.local.password);
};

userSchema.methods.generateJwt = function() {
  var expiry = new Date();
  expiry.setDate(expiry.getDate() + 7);

  return jwt.sign({
    _id: this._id,
    email: this.local.email,
    username: this.local.username,
    role : this.role,
    exp: parseInt(expiry.getTime() / 1000),
  }, 'TEAMSECRETSUCKS'); // DO NOT KEEP YOUR SECRET IN THE CODE!
};

userSchema.methods.addProfilePicture = function(pictureUrl){
  console.log('PICTURE URL : ', pictureUrl)
  this.image = pictureUrl;
}
// Create the model for users and expose it to the app
export default mongoose.model('User', userSchema);


text:
package org.kc7bfi.jflac.frame;

/**
 * BadHeaderException.
 * @author kc7bfi
 */
public class BadHeaderException extends Exception {

    /**
     * Exception constructor.
     */
    public BadHeaderException() {
        super();
    }

    /**
     * Exception constructor.
     * @param msg   The exception message
     */
    public BadHeaderException(String msg) {
        super(msg);
    }

    /**
     * Exception constructor.
     * @param err   The throwable error
     */
    public BadHeaderException(Throwable err) {
        super(err);
    }

    /**
     * Exception constructor.
     * @param msg   The exception message
     * @param err   The throwable error
     */
    public BadHeaderException(String msg, Throwable err) {
        super(msg, err);
    }

}


text:
//===-- LlvmState.cpp -------------------------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include "LlvmState.h"
#include "Target.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/MC/MCCodeEmitter.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCFixup.h"
#include "llvm/MC/MCObjectFileInfo.h"
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"

namespace exegesis {

LLVMState::LLVMState(const std::string &Triple, const std::string &CpuName) {
  std::string Error;
  const llvm::Target *const TheTarget =
      llvm::TargetRegistry::lookupTarget(Triple, Error);
  assert(TheTarget && "unknown target for host");
  const llvm::TargetOptions Options;
  TargetMachine.reset(static_cast<llvm::LLVMTargetMachine *>(
      TheTarget->createTargetMachine(Triple, CpuName, /*Features*/ "", Options,
                                     llvm::Reloc::Model::Static)));
  TheExegesisTarget = ExegesisTarget::lookup(TargetMachine->getTargetTriple());
  if (!TheExegesisTarget) {
    llvm::errs() << "no exegesis target for " << Triple << ", using default\n";
    TheExegesisTarget = &ExegesisTarget::getDefault();
  }
}

LLVMState::LLVMState()
    : LLVMState(llvm::sys::getProcessTriple(),
                llvm::sys::getHostCPUName().str()) {}

std::unique_ptr<llvm::LLVMTargetMachine>
LLVMState::createTargetMachine() const {
  return std::unique_ptr<llvm::LLVMTargetMachine>(
      static_cast<llvm::LLVMTargetMachine *>(
          TargetMachine->getTarget().createTargetMachine(
              TargetMachine->getTargetTriple().normalize(),
              TargetMachine->getTargetCPU(),
              TargetMachine->getTargetFeatureString(), TargetMachine->Options,
              llvm::Reloc::Model::Static)));
}

bool LLVMState::canAssemble(const llvm::MCInst &Inst) const {
  llvm::MCObjectFileInfo ObjectFileInfo;
  llvm::MCContext Context(TargetMachine->getMCAsmInfo(),
                          TargetMachine->getMCRegisterInfo(), &ObjectFileInfo);
  std::unique_ptr<const llvm::MCCodeEmitter> CodeEmitter(
      TargetMachine->getTarget().createMCCodeEmitter(
          *TargetMachine->getMCInstrInfo(), *TargetMachine->getMCRegisterInfo(),
          Context));
  llvm::SmallVector<char, 16> Tmp;
  llvm::raw_svector_ostream OS(Tmp);
  llvm::SmallVector<llvm::MCFixup, 4> Fixups;
  CodeEmitter->encodeInstruction(Inst, OS, Fixups,
                                 *TargetMachine->getMCSubtargetInfo());
  return Tmp.size() > 0;
}

} // namespace exegesis


text:
<?php

/**
* A ReCaptchaResponse is returned from recaptcha_check_answer()
*/
class ReCaptcha_Response
{
	var $is_valid;
	var $error;
}


text:
var specificQuestion = require('./questions').specific;

// Specific answer has this path fragment.
exports.specific = specificQuestion + '/answer/:answer_id';
var specific = exports.specific;

exports.route = function (app, controllers, doc) {
    var route = require('../route')(app, controllers, doc, __filename);

    route('post', specificQuestion + '/answers', 'create', 'Create; Add new answer to question');

    route('post', specific + '/upvote', 'upvote', 'Upvote; Upvote answer');

    route('post', specific + '/downvote', 'downvote', 'Downvote; Downvote answer');

    route('post', '/getVideoHtml', 'getVideoHtml', 'Downvote; Downvote answer');

    route('get', specificQuestion + '/answers', 'all', 'Get all answers for a specific question; Get all answers for a specific question');

    route('get', '/answers', 'allEver', 'Get All; Get all answers ever stored in the datastore');

    route('get', specific, 'get', 'Get; Get answer with specific ID');

    route('put', specific, 'update', 'Update; Update answer');

    route('delete', specific, 'remove', 'Delete; Delete answer');

    route('head', specific, 'head', 'Head; Get headers for testing validity, accessibility, and recent modification');
};


text:
package org.newdawn.slick.command;

/**
 * A control indicating that a particular direction must be pressed or released on a controller to cause the command to
 * fire
 *

 *
 * @author kevin
 */
public class ControllerDirectionControl extends ControllerControl {

    /**
     * The direction indicating we're waiting for the user to press left
     */
    public static final Direction LEFT = new Direction(LEFT_EVENT);

    /**
     * The direction indicating we're waiting for the user to press up
     */
    public static final Direction UP = new Direction(UP_EVENT);

    /**
     * The direction indicating we're waiting for the user to press down
     */
    public static final Direction DOWN = new Direction(DOWN_EVENT);

    /**
     * The direction indicating we're waiting for the user to press right
     */
    public static final Direction RIGHT = new Direction(RIGHT_EVENT);

    /**
     * Create a new input that indicates a direcitonal control must be pressed
     *

     *
     * @param controllerIndex The index of the controller to listen to
     * @param dir             The direction to wait for
     */
    public ControllerDirectionControl(int controllerIndex, Direction dir) {
        super(controllerIndex, dir.event, 0);
    }

    /**
     * Enum pretender
     *

     *
     * @author kevin
     */
    private static class Direction {

        /**
         * The event to be fired for this direction
         */
        private int event;

        /**
         * Create a new direction indicator/enum value
         *

         *
         * @param event The event to fire when this direction is used
         */
        public Direction(int event) {
            this.event = event;
        }

    }
}


text:
package org.ovirt.engine.core.common.queries;

public class GetTagUserGroupMapByTagNameParameters extends GetTagByTagNameParametersBase {
    private static final long serialVersionUID = -4848218011737609408L;

    public GetTagUserGroupMapByTagNameParameters(String tagName) {
        super(tagName);
    }

    public GetTagUserGroupMapByTagNameParameters() {
    }
}


text:
<Record>
<Term>Lutetium Lu-177-DOTA-Chimeric Monoclonal Antibody cG250</Term>
<SemanticType>Pharmacologic Substance</SemanticType>
<ParentTerm>Radioimmunoconjugate</ParentTerm>
<ClassificationPath>Chemicals_and_Drugs_Kind/Drug, Food, Chemical or Biomedical Material/Pharmacologic Substance/Radiopharmaceutical Compound/Radioimmunoconjugate/Lutetium Lu-177-DOTA-Chimeric Monoclonal Antibody cG250</ClassificationPath>
<BroaderTerm>Radioimmunoconjugate</BroaderTerm>
<BroaderTerm>Radiopharmaceutical Compound</BroaderTerm>
<BroaderTerm>Chemicals_and_Drugs_Kind</BroaderTerm>
<BroaderTerm>Pharmacologic Substance</BroaderTerm>
<BroaderTerm>Lutetium Lu-177-DOTA-Chimeric Monoclonal Antibody cG250</BroaderTerm>
<BroaderTerm>Drug, Food, Chemical or Biomedical Material</BroaderTerm>
<Synonym>177Lu-DOTA-cG250</Synonym>
<Synonym>Lutetium Lu-177-DOTA-Chimeric Monoclonal Antibody cG250</Synonym>
<Synonym>Lutetium-177 Labeled cG250</Synonym>
<Synonym>Yttrium-90 DOTA Conjugated Chimeric MoAb G250</Synonym>
<Description>A radioimmunoconjugate consisting of the chimeric monoclonal antibody cG250 linked to the low energy beta-emitting radioisotope Lutetium 177, via the bifunctional macrocyclic chelating agent tetra-azacyclododecanetetra-acetic acid (DOTA), with potential antineoplastic activity. The antibody moiety of lutetium Lu-177-DOTA-chimeric monoclonal antibody cG250 binds to renal cell carcinoma (RCC) cells expressing the RCC-associated antigen G250; a cytotoxic dose of beta radiation is selectively delivered to G250-expressing RCC cells upon internalization of the radioimmunoconjugate.</Description>
<Source>NCI Thesaurus</Source>
</Record>


text:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <Button
        android:id="@+id/bt1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="bt1" />

    <Button
        android:id="@+id/bt2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="bt2" />

    <Button
        android:id="@+id/bt3"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="bt3" />

    <Button
        android:id="@+id/bt4"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="bt4" />

    <Button
        android:id="@+id/bt5"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="bt5" />

</LinearLayout>


text:
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.maps.implementation;

import com.azure.core.annotation.BodyParam;
import com.azure.core.annotation.Delete;
import com.azure.core.annotation.ExpectedResponses;
import com.azure.core.annotation.Get;
import com.azure.core.annotation.HeaderParam;
import com.azure.core.annotation.Headers;
import com.azure.core.annotation.Host;
import com.azure.core.annotation.HostParam;
import com.azure.core.annotation.Patch;
import com.azure.core.annotation.PathParam;
import com.azure.core.annotation.Put;
import com.azure.core.annotation.QueryParam;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceInterface;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.annotation.UnexpectedResponseExceptionType;
import com.azure.core.http.rest.PagedFlux;
import com.azure.core.http.rest.PagedIterable;
import com.azure.core.http.rest.PagedResponse;
import com.azure.core.http.rest.PagedResponseBase;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.RestProxy;
import com.azure.core.management.exception.ManagementException;
import com.azure.core.util.Context;
import com.azure.core.util.FluxUtil;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.maps.fluent.CreatorsClient;
import com.azure.resourcemanager.maps.fluent.models.CreatorInner;
import com.azure.resourcemanager.maps.models.CreatorList;
import com.azure.resourcemanager.maps.models.CreatorUpdateParameters;
import reactor.core.publisher.Mono;

/** An instance of this class provides access to all the operations defined in CreatorsClient. */
public final class CreatorsClientImpl implements CreatorsClient {
    private final ClientLogger logger = new ClientLogger(CreatorsClientImpl.class);

    /** The proxy service used to perform REST calls. */
    private final CreatorsService service;

    /** The service client containing this operation class. */
    private final AzureMapsManagementClientImpl client;

    /**
     * Initializes an instance of CreatorsClientImpl.
     *
     * @param client the instance of the service client containing this operation class.
     */
    CreatorsClientImpl(AzureMapsManagementClientImpl client) {
        this.service = RestProxy.create(CreatorsService.class, client.getHttpPipeline(), client.getSerializerAdapter());
        this.client = client;
    }

    /**
     * The interface defining all the services for AzureMapsManagementClientCreators to be used by the proxy service to
     * perform REST calls.
     */
    @Host("{$host}")
    @ServiceInterface(name = "AzureMapsManagementC")
    private interface CreatorsService {
        @Headers({"Content-Type: application/json"})
        @Get(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts"
                + "/{accountName}/creators")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<CreatorList>> listByAccount(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("accountName") String accountName,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Put(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts"
                + "/{accountName}/creators/{creatorName}")
        @ExpectedResponses({200, 201})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<CreatorInner>> createOrUpdate(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("accountName") String accountName,
            @PathParam("creatorName") String creatorName,
            @BodyParam("application/json") CreatorInner creatorResource,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Patch(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts"
                + "/{accountName}/creators/{creatorName}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<CreatorInner>> update(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("accountName") String accountName,
            @PathParam("creatorName") String creatorName,
            @BodyParam("application/json") CreatorUpdateParameters creatorUpdateParameters,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Delete(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts"
                + "/{accountName}/creators/{creatorName}")
        @ExpectedResponses({200, 204})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Void>> delete(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("accountName") String accountName,
            @PathParam("creatorName") String creatorName,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Get(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts"
                + "/{accountName}/creators/{creatorName}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<CreatorInner>> get(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("accountName") String accountName,
            @PathParam("creatorName") String creatorName,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Get("{nextLink}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<CreatorList>> listByAccountNext(
            @PathParam(value = "nextLink", encoded = true) String nextLink,
            @HostParam("$host") String endpoint,
            @HeaderParam("Accept") String accept,
            Context context);
    }

    /**
     * Get all Creator instances for an Azure Maps Account.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param accountName The name of the Maps Account.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return all Creator instances for an Azure Maps Account.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<CreatorInner>> listByAccountSinglePageAsync(
        String resourceGroupName, String accountName) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (accountName == null) {
            return Mono.error(new IllegalArgumentException("Parameter accountName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .listByAccount(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            accountName,
                            accept,
                            context))
            .<PagedResponse<CreatorInner>>map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Get all Creator instances for an Azure Maps Account.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param accountName The name of the Maps Account.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return all Creator instances for an Azure Maps Account.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<CreatorInner>> listByAccountSinglePageAsync(
        String resourceGroupName, String accountName, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (accountName == null) {
            return Mono.error(new IllegalArgumentException("Parameter accountName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .listByAccount(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                accountName,
                accept,
                context)
            .map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null));
    }

    /**
     * Get all Creator instances for an Azure Maps Account.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param accountName The name of the Maps Account.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return all Creator instances for an Azure Maps Account.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<CreatorInner> listByAccountAsync(String resourceGroupName, String accountName) {
        return new PagedFlux<>(
            () -> listByAccountSinglePageAsync(resourceGroupName, accountName),
            nextLink -> listByAccountNextSinglePageAsync(nextLink));
    }

    /**
     * Get all Creator instances for an Azure Maps Account.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param accountName The name of the Maps Account.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return all Creator instances for an Azure Maps Account.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<CreatorInner> listByAccountAsync(String resourceGroupName, String accountName, Context context) {
        return new PagedFlux<>(
            () -> listByAccountSinglePageAsync(resourceGroupName, accountName, context),
            nextLink -> listByAccountNextSinglePageAsync(nextLink, context));
    }

    /**
     * Get all Creator instances for an Azure Maps Account.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param accountName The name of the Maps Account.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return all Creator instances for an Azure Maps Account.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<CreatorInner> listByAccount(String resourceGroupName, String accountName) {
        return new PagedIterable<>(listByAccountAsync(resourceGroupName, accountName));
    }

    /**
     * Get all Creator instances for an Azure Maps Account.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param accountName The name of the Maps Account.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return all Creator instances for an Azure Maps Account.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<CreatorInner> listByAccount(String resourceGroupName, String accountName, Context context) {
        return new PagedIterable<>(listByAccountAsync(resourceGroupName, accountName, context));
    }

    /**
     * Create or update a Maps Creator resource. Creator resource will manage Azure resources required to populate a
     * custom set of mapping data. It requires an account to exist before it can be created.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param accountName The name of the Maps Account.
     * @param creatorName The name of the Maps Creator instance.
     * @param creatorResource The new or updated parameters for the Creator resource.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return an Azure resource which represents Maps Creator product and provides ability to manage private location
     *     data.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<CreatorInner>> createOrUpdateWithResponseAsync(
        String resourceGroupName, String accountName, String creatorName, CreatorInner creatorResource) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (accountName == null) {
            return Mono.error(new IllegalArgumentException("Parameter accountName is required and cannot be null."));
        }
        if (creatorName == null) {
            return Mono.error(new IllegalArgumentException("Parameter creatorName is required and cannot be null."));
        }
        if (creatorResource == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter creatorResource is required and cannot be null."));
        } else {
            creatorResource.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .createOrUpdate(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            accountName,
                            creatorName,
                            creatorResource,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Create or update a Maps Creator resource. Creator resource will manage Azure resources required to populate a
     * custom set of mapping data. It requires an account to exist before it can be created.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param accountName The name of the Maps Account.
     * @param creatorName The name of the Maps Creator instance.
     * @param creatorResource The new or updated parameters for the Creator resource.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return an Azure resource which represents Maps Creator product and provides ability to manage private location
     *     data.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<CreatorInner>> createOrUpdateWithResponseAsync(
        String resourceGroupName,
        String accountName,
        String creatorName,
        CreatorInner creatorResource,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (accountName == null) {
            return Mono.error(new IllegalArgumentException("Parameter accountName is required and cannot be null."));
        }
        if (creatorName == null) {
            return Mono.error(new IllegalArgumentException("Parameter creatorName is required and cannot be null."));
        }
        if (creatorResource == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter creatorResource is required and cannot be null."));
        } else {
            creatorResource.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .createOrUpdate(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                accountName,
                creatorName,
                creatorResource,
                accept,
                context);
    }

    /**
     * Create or update a Maps Creator resource. Creator resource will manage Azure resources required to populate a
     * custom set of mapping data. It requires an account to exist before it can be created.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param accountName The name of the Maps Account.
     * @param creatorName The name of the Maps Creator instance.
     * @param creatorResource The new or updated parameters for the Creator resource.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return an Azure resource which represents Maps Creator product and provides ability to manage private location
     *     data.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<CreatorInner> createOrUpdateAsync(
        String resourceGroupName, String accountName, String creatorName, CreatorInner creatorResource) {
        return createOrUpdateWithResponseAsync(resourceGroupName, accountName, creatorName, creatorResource)
            .flatMap(
                (Response<CreatorInner> res) -> {
                    if (res.getValue() != null) {
                        return Mono.just(res.getValue());
                    } else {
                        return Mono.empty();
                    }
                });
    }

    /**
     * Create or update a Maps Creator resource. Creator resource will manage Azure resources required to populate a
     * custom set of mapping data. It requires an account to exist before it can be created.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param accountName The name of the Maps Account.
     * @param creatorName The name of the Maps Creator instance.
     * @param creatorResource The new or updated parameters for the Creator resource.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return an Azure resource which represents Maps Creator product and provides ability to manage private location
     *     data.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public CreatorInner createOrUpdate(
        String resourceGroupName, String accountName, String creatorName, CreatorInner creatorResource) {
        return createOrUpdateAsync(resourceGroupName, accountName, creatorName, creatorResource).block();
    }

    /**
     * Create or update a Maps Creator resource. Creator resource will manage Azure resources required to populate a
     * custom set of mapping data. It requires an account to exist before it can be created.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param accountName The name of the Maps Account.
     * @param creatorName The name of the Maps Creator instance.
     * @param creatorResource The new or updated parameters for the Creator resource.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return an Azure resource which represents Maps Creator product and provides ability to manage private location
     *     data.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<CreatorInner> createOrUpdateWithResponse(
        String resourceGroupName,
        String accountName,
        String creatorName,
        CreatorInner creatorResource,
        Context context) {
        return createOrUpdateWithResponseAsync(resourceGroupName, accountName, creatorName, creatorResource, context)
            .block();
    }

    /**
     * Updates the Maps Creator resource. Only a subset of the parameters may be updated after creation, such as Tags.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param accountName The name of the Maps Account.
     * @param creatorName The name of the Maps Creator instance.
     * @param creatorUpdateParameters The update parameters for Maps Creator.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return an Azure resource which represents Maps Creator product and provides ability to manage private location
     *     data.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<CreatorInner>> updateWithResponseAsync(
        String resourceGroupName,
        String accountName,
        String creatorName,
        CreatorUpdateParameters creatorUpdateParameters) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (accountName == null) {
            return Mono.error(new IllegalArgumentException("Parameter accountName is required and cannot be null."));
        }
        if (creatorName == null) {
            return Mono.error(new IllegalArgumentException("Parameter creatorName is required and cannot be null."));
        }
        if (creatorUpdateParameters == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter creatorUpdateParameters is required and cannot be null."));
        } else {
            creatorUpdateParameters.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .update(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            accountName,
                            creatorName,
                            creatorUpdateParameters,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Updates the Maps Creator resource. Only a subset of the parameters may be updated after creation, such as Tags.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param accountName The name of the Maps Account.
     * @param creatorName The name of the Maps Creator instance.
     * @param creatorUpdateParameters The update parameters for Maps Creator.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return an Azure resource which represents Maps Creator product and provides ability to manage private location
     *     data.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<CreatorInner>> updateWithResponseAsync(
        String resourceGroupName,
        String accountName,
        String creatorName,
        CreatorUpdateParameters creatorUpdateParameters,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (accountName == null) {
            return Mono.error(new IllegalArgumentException("Parameter accountName is required and cannot be null."));
        }
        if (creatorName == null) {
            return Mono.error(new IllegalArgumentException("Parameter creatorName is required and cannot be null."));
        }
        if (creatorUpdateParameters == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter creatorUpdateParameters is required and cannot be null."));
        } else {
            creatorUpdateParameters.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .update(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                accountName,
                creatorName,
                creatorUpdateParameters,
                accept,
                context);
    }

    /**
     * Updates the Maps Creator resource. Only a subset of the parameters may be updated after creation, such as Tags.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param accountName The name of the Maps Account.
     * @param creatorName The name of the Maps Creator instance.
     * @param creatorUpdateParameters The update parameters for Maps Creator.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return an Azure resource which represents Maps Creator product and provides ability to manage private location
     *     data.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<CreatorInner> updateAsync(
        String resourceGroupName,
        String accountName,
        String creatorName,
        CreatorUpdateParameters creatorUpdateParameters) {
        return updateWithResponseAsync(resourceGroupName, accountName, creatorName, creatorUpdateParameters)
            .flatMap(
                (Response<CreatorInner> res) -> {
                    if (res.getValue() != null) {
                        return Mono.just(res.getValue());
                    } else {
                        return Mono.empty();
                    }
                });
    }

    /**
     * Updates the Maps Creator resource. Only a subset of the parameters may be updated after creation, such as Tags.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param accountName The name of the Maps Account.
     * @param creatorName The name of the Maps Creator instance.
     * @param creatorUpdateParameters The update parameters for Maps Creator.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return an Azure resource which represents Maps Creator product and provides ability to manage private location
     *     data.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public CreatorInner update(
        String resourceGroupName,
        String accountName,
        String creatorName,
        CreatorUpdateParameters creatorUpdateParameters) {
        return updateAsync(resourceGroupName, accountName, creatorName, creatorUpdateParameters).block();
    }

    /**
     * Updates the Maps Creator resource. Only a subset of the parameters may be updated after creation, such as Tags.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param accountName The name of the Maps Account.
     * @param creatorName The name of the Maps Creator instance.
     * @param creatorUpdateParameters The update parameters for Maps Creator.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return an Azure resource which represents Maps Creator product and provides ability to manage private location
     *     data.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<CreatorInner> updateWithResponse(
        String resourceGroupName,
        String accountName,
        String creatorName,
        CreatorUpdateParameters creatorUpdateParameters,
        Context context) {
        return updateWithResponseAsync(resourceGroupName, accountName, creatorName, creatorUpdateParameters, context)
            .block();
    }

    /**
     * Delete a Maps Creator resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param accountName The name of the Maps Account.
     * @param creatorName The name of the Maps Creator instance.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the completion.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Void>> deleteWithResponseAsync(
        String resourceGroupName, String accountName, String creatorName) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (accountName == null) {
            return Mono.error(new IllegalArgumentException("Parameter accountName is required and cannot be null."));
        }
        if (creatorName == null) {
            return Mono.error(new IllegalArgumentException("Parameter creatorName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .delete(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            accountName,
                            creatorName,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Delete a Maps Creator resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param accountName The name of the Maps Account.
     * @param creatorName The name of the Maps Creator instance.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the completion.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Void>> deleteWithResponseAsync(
        String resourceGroupName, String accountName, String creatorName, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (accountName == null) {
            return Mono.error(new IllegalArgumentException("Parameter accountName is required and cannot be null."));
        }
        if (creatorName == null) {
            return Mono.error(new IllegalArgumentException("Parameter creatorName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .delete(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                accountName,
                creatorName,
                accept,
                context);
    }

    /**
     * Delete a Maps Creator resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param accountName The name of the Maps Account.
     * @param creatorName The name of the Maps Creator instance.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the completion.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Void> deleteAsync(String resourceGroupName, String accountName, String creatorName) {
        return deleteWithResponseAsync(resourceGroupName, accountName, creatorName)
            .flatMap((Response<Void> res) -> Mono.empty());
    }

    /**
     * Delete a Maps Creator resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param accountName The name of the Maps Account.
     * @param creatorName The name of the Maps Creator instance.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public void delete(String resourceGroupName, String accountName, String creatorName) {
        deleteAsync(resourceGroupName, accountName, creatorName).block();
    }

    /**
     * Delete a Maps Creator resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param accountName The name of the Maps Account.
     * @param creatorName The name of the Maps Creator instance.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the response.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<Void> deleteWithResponse(
        String resourceGroupName, String accountName, String creatorName, Context context) {
        return deleteWithResponseAsync(resourceGroupName, accountName, creatorName, context).block();
    }

    /**
     * Get a Maps Creator resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param accountName The name of the Maps Account.
     * @param creatorName The name of the Maps Creator instance.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a Maps Creator resource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<CreatorInner>> getWithResponseAsync(
        String resourceGroupName, String accountName, String creatorName) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (accountName == null) {
            return Mono.error(new IllegalArgumentException("Parameter accountName is required and cannot be null."));
        }
        if (creatorName == null) {
            return Mono.error(new IllegalArgumentException("Parameter creatorName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .get(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            accountName,
                            creatorName,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Get a Maps Creator resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param accountName The name of the Maps Account.
     * @param creatorName The name of the Maps Creator instance.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a Maps Creator resource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<CreatorInner>> getWithResponseAsync(
        String resourceGroupName, String accountName, String creatorName, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (accountName == null) {
            return Mono.error(new IllegalArgumentException("Parameter accountName is required and cannot be null."));
        }
        if (creatorName == null) {
            return Mono.error(new IllegalArgumentException("Parameter creatorName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .get(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                accountName,
                creatorName,
                accept,
                context);
    }

    /**
     * Get a Maps Creator resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param accountName The name of the Maps Account.
     * @param creatorName The name of the Maps Creator instance.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a Maps Creator resource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<CreatorInner> getAsync(String resourceGroupName, String accountName, String creatorName) {
        return getWithResponseAsync(resourceGroupName, accountName, creatorName)
            .flatMap(
                (Response<CreatorInner> res) -> {
                    if (res.getValue() != null) {
                        return Mono.just(res.getValue());
                    } else {
                        return Mono.empty();
                    }
                });
    }

    /**
     * Get a Maps Creator resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param accountName The name of the Maps Account.
     * @param creatorName The name of the Maps Creator instance.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a Maps Creator resource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public CreatorInner get(String resourceGroupName, String accountName, String creatorName) {
        return getAsync(resourceGroupName, accountName, creatorName).block();
    }

    /**
     * Get a Maps Creator resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param accountName The name of the Maps Account.
     * @param creatorName The name of the Maps Creator instance.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a Maps Creator resource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<CreatorInner> getWithResponse(
        String resourceGroupName, String accountName, String creatorName, Context context) {
        return getWithResponseAsync(resourceGroupName, accountName, creatorName, context).block();
    }

    /**
     * Get the next page of items.
     *
     * @param nextLink The nextLink parameter.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of Creator resources.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<CreatorInner>> listByAccountNextSinglePageAsync(String nextLink) {
        if (nextLink == null) {
            return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
        }
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.listByAccountNext(nextLink, this.client.getEndpoint(), accept, context))
            .<PagedResponse<CreatorInner>>map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Get the next page of items.
     *
     * @param nextLink The nextLink parameter.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of Creator resources.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<CreatorInner>> listByAccountNextSinglePageAsync(String nextLink, Context context) {
        if (nextLink == null) {
            return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
        }
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .listByAccountNext(nextLink, this.client.getEndpoint(), accept, context)
            .map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null));
    }
}


text:
/* ----------------------------------------------------------------------------
 * This file was automatically generated by SWIG (http://www.swig.org).
 * Version 3.0.10
 *
 * Do not make changes to this file unless you know what you are doing--modify
 * the SWIG interface file instead.
 * ----------------------------------------------------------------------------- */

package com.badlogic.gdx.physics.bullet.collision;

public final class PHY_ScalarType {
  public final static int PHY_FLOAT = 0;
  public final static int PHY_DOUBLE = PHY_FLOAT + 1;
  public final static int PHY_INTEGER = PHY_DOUBLE + 1;
  public final static int PHY_SHORT = PHY_INTEGER + 1;
  public final static int PHY_FIXEDPOINT88 = PHY_SHORT + 1;
  public final static int PHY_UCHAR = PHY_FIXEDPOINT88 + 1;
}


text:
using System.Linq;
using Difi.SikkerDigitalPost.Klient.Domene.Entiteter.Post;
using Difi.SikkerDigitalPost.Klient.Domene.Enums;
using Difi.SikkerDigitalPost.Klient.Tester.Utilities;
using Xunit;

namespace Difi.SikkerDigitalPost.Klient.Tester.Entiteter.Post
{
    public class ForsendelseTests
    {
        public class ConstructorMethod : ForsendelseTests
        {
            [Fact]
            public void SuccessfullySetsLanguageOnDocumentsWithNoLanguageCodeFromMessage()
            {
                //Arrange
                var sender = DomainUtility.GetAvsender();
                var simpleDigitalPostInfo = DomainUtility.GetDigitalPostInfoSimple();

                string undefinedLanguageCode = null;
                var primaryDocument = new Dokument("Tiitle", new byte[3], "application/pdf", undefinedLanguageCode);
                var documentBundle = new Dokumentpakke(primaryDocument);
                var definedLanguageCode = "en";
                documentBundle.LeggTilVedlegg(new Dokument("Appendix", new byte[2], "application/pdf", definedLanguageCode));

                var messageLanguageCode = "no";
                //Act
                var forsendelse = new Forsendelse(sender, simpleDigitalPostInfo, documentBundle, Prioritet.Normal, "mpcId", messageLanguageCode);

                //Assert
                Assert.Equal(messageLanguageCode, documentBundle.Hoveddokument.Språkkode);
                Assert.Equal(definedLanguageCode, documentBundle.Vedlegg.First().Språkkode);
            }
        }
    }
}


text:
module Stripetie
  module Customer
    def self.included(base)
      base.class_eval do
        has_many :invoices, class_name: 'Invoice', primary_key: 'stripe_customer_id', foreign_key: 'customer', dependent: :destroy
        belongs_to :account
        #! Fill in all the other has_many, belong_to, etc.
      end
    end
    #Create and associate stripe customer ID to a customer
    def create_and_associate_stripe_customer(stripe_token, account_id = nil)
      Stripe.api_key = ENV['STRIPE_PLATFORM_SECRET_KEY']
      stripe_account_id = Account.find_by_id(account_id).try(:stripe_account_id) #! Need to make 'Account' model name dynamic
      if stripe_account_id
        stripe_customer = Stripe::Customer.create({source: stripe_token},{stripe_account: stripe_account_id})
      else
        stripe_customer = Stripe::Customer.create(source: stripe_token)
      end
      self.stripe_customer_id = stripe_customer['id']
      self.save!
    end

    #Retrieve the Stripe customer object from Stripe
    def stripe_customer(account_id = nil)
      Stripe.api_key = ENV['STRIPE_PLATFORM_SECRET_KEY']
      stripe_account_id = ::Account.find_by_id(account_id).try(:stripe_account_id)
      if stripe_account_id
        Stripe::Customer.retrieve(self.stripe_customer_id)
      else
        Stripe::Customer.retrieve(self.stripe_customer_id, {stripe_account: stripe_account_id})
      end
    end

    def cards
      sc = self.stripe_customer
      cards = sc.sources.all.as_json['data']
    end
  end
end


text:
// Copyright 2015 The Bazel Authors. All rights reserved.
//
// 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.google.devtools.build.lib.analysis.constraints;

import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
import com.google.devtools.build.lib.packages.EnvironmentGroup;

import java.util.Map;

/**
 * Contains a set of {@link Environment} labels and their associated groups.
 */
@Immutable
public class EnvironmentCollection {
  private final ImmutableMultimap<EnvironmentGroup, Label> map;

  private EnvironmentCollection(ImmutableMultimap<EnvironmentGroup, Label> map) {
    this.map = map;
  }

  /**
   * Stores an environment's build label along with the group it belongs to.
   */
  @AutoValue
  abstract static class EnvironmentWithGroup {
    static EnvironmentWithGroup create(Label environment, EnvironmentGroup group) {
      return new AutoValue_EnvironmentCollection_EnvironmentWithGroup(environment, group);
    }
    abstract Label environment();
    abstract EnvironmentGroup group();
  }

  /**
   * Returns the build labels of each environment in this collection, ordered by
   * their insertion order in {@link Builder}.
   */
  public ImmutableCollection<Label> getEnvironments() {
    return map.values();
  }

  /**
   * Returns the set of groups the environments in this collection belong to, ordered by
   * their insertion order in {@link Builder}
   */
  ImmutableSet<EnvironmentGroup> getGroups() {
    return map.keySet();
  }

  /**
   * Returns the build labels of each environment in this collection paired with the
   * group each environment belongs to, ordered by their insertion order in {@link Builder}.
   */
  ImmutableCollection<EnvironmentWithGroup> getGroupedEnvironments() {
    ImmutableSet.Builder<EnvironmentWithGroup> builder = ImmutableSet.builder();
    for (Map.Entry<EnvironmentGroup, Label> entry : map.entries()) {
      builder.add(EnvironmentWithGroup.create(entry.getValue(), entry.getKey()));
    }
    return builder.build();
  }

  /**
   * Returns the environments in this collection that belong to the given group, ordered by
   * their insertion order in {@link Builder}. If no environments belong to the given group,
   * returns an empty collection.
   */
  ImmutableCollection<Label> getEnvironments(EnvironmentGroup group) {
    return map.get(group);
  }

  /**
   * An empty collection.
   */
  static final EnvironmentCollection EMPTY =
      new EnvironmentCollection(ImmutableMultimap.<EnvironmentGroup, Label>of());

  /**
   * Builder for {@link EnvironmentCollection}.
   */
  public static class Builder {
    private final ImmutableMultimap.Builder<EnvironmentGroup, Label> mapBuilder =
        ImmutableMultimap.builder();

    /**
     * Inserts the given environment / owning group pair.
     */
    public Builder put(EnvironmentGroup group, Label environment) {
      mapBuilder.put(group, environment);
      return this;
    }

    /**
     * Inserts the given set of environments, all belonging to the specified group.
     */
    public Builder putAll(EnvironmentGroup group, Iterable<Label> environments) {
      mapBuilder.putAll(group, environments);
      return this;
    }

    /**
     * Inserts the contents of another {@link EnvironmentCollection} into this one.
     */
    public Builder putAll(EnvironmentCollection other) {
      mapBuilder.putAll(other.map);
      return this;
    }

    public EnvironmentCollection build() {
      return new EnvironmentCollection(mapBuilder.build());
    }
  }
}


text:
package vandy.mooc.provider;

import android.content.ContentProvider;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.UriMatcher;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.net.Uri;

/**
 * Content Provider to access Acronym Database.
 */
public class AcronymProvider extends ContentProvider {
	/**
	 * Debugging tag used by the Android logger.
	 */
	private static final String TAG = AcronymProvider.class.getSimpleName();

	/**
	 * Use AcronymDatabaseHelper to manage database creation and version management.
	 */
	private AcronymDatabaseHelper mOpenHelper;

	/**
	 * The code that is returned when a URI for more than 1 items is matched against the given components. Must be
	 * positive.
	 */
	private static final int ACRONYMS = 100;

	/**
	 * The code that is returned when a URI for exactly 1 item is matched against the given components. Must be
	 * positive.
	 */
	private static final int ACRONYM = 101;

	/**
	 * The URI Matcher used by this content provider.
	 */
	private static final UriMatcher sUriMatcher = buildUriMatcher();

	/**
	 * Helper method to match each URI to the ACRONYM integers constant defined above.
	 *
	 * @return UriMatcher
	 */
	private static UriMatcher buildUriMatcher() {
		// All paths added to the UriMatcher have a corresponding code
		// to return when a match is found.  The code passed into the
		// constructor represents the code to return for the rootURI.
		// It's common to use NO_MATCH as the code for this case.
		final UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH);

		// For each type of URI that is added, a corresponding code is
		// created.
		matcher.addURI(AcronymContract.CONTENT_AUTHORITY, AcronymContract.PATH_ACRONYM, ACRONYMS);
		matcher.addURI(AcronymContract.CONTENT_AUTHORITY, AcronymContract.PATH_ACRONYM + "/#", ACRONYM);
		return matcher;
	}

	/**
	 * Hook method called when Database is created to initialize the Database Helper that provides access to the Acronym
	 * Database.
	 */
	@Override
	public boolean onCreate() {
		mOpenHelper = new AcronymDatabaseHelper(getContext());
		return true;
	}

	/**
	 * Hook method called to handle requests for the MIME type of the data at the given URI. The returned MIME type
	 * should start with vnd.android.cursor.item for a single item or vnd.android.cursor.dir/ for multiple items.
	 */
	@Override
	public String getType(Uri uri) {
		// Use Uri Matcher to determine what kind of URI this is.
		final int match = sUriMatcher.match(uri);

		// Match the id returned by UriMatcher to return appropriate
		// MIME_TYPE.
		switch (match) {
			case ACRONYMS:
				return AcronymContract.AcronymEntry.CONTENT_ITEMS_TYPE;
			case ACRONYM:
				return AcronymContract.AcronymEntry.CONTENT_ITEM_TYPE;
			default:
				throw new UnsupportedOperationException("Unknown uri: " + uri);
		}
	}

	/**
	 * Hook method called to handle requests to insert a new row. As a courtesy, notifyChange() is called after
	 * inserting.
	 */
	@Override
	public Uri insert(Uri uri, ContentValues values) {
		// Create and/or open a database that will be used for reading
		// and writing. Once opened successfully, the database is
		// cached, so you can call this method every time you need to
		// write to the database.
		final SQLiteDatabase db = mOpenHelper.getWritableDatabase();

		Uri returnUri;

		// Try to match against the path in a url.  It returns the
		// code for the matched node (added using addURI), or -1 if
		// there is no matched node.  If there's a match insert a new
		// row.
		switch (sUriMatcher.match(uri)) {
			case ACRONYMS:
				// TODOne - replace 0 with code that inserts a row in Table
				// and returns the row id.
				long id = db.insert(AcronymContract.AcronymEntry.TABLE_NAME, null, values);

				// Check if a new row is inserted or not.
				if (id > 0) {
					returnUri = AcronymContract.AcronymEntry.buildAcronymUri(id);
				} else {
					throw new android.database.SQLException("Failed to insert row into " + uri);
				}
				break;
			default:
				throw new UnsupportedOperationException("Unknown uri: " + uri);
		}

		// Notifies registered observers that a row was inserted.
		getContext().getContentResolver().notifyChange(uri, null);
		return returnUri;
	}

	// Hook method to handle requests to insert a set of new rows, or
	// the default implementation will iterate over the values and
	// call insert on each of them. As a courtesy, call notifyChange()
	// after inserting.
	@Override
	public int bulkInsert(Uri uri, ContentValues[] contentValues) {
		// Create and/or open a database that will be used for reading
		// and writing. Once opened successfully, the database is
		// cached, so you can call this method every time you need to
		// write to the database.
		final SQLiteDatabase db = mOpenHelper.getWritableDatabase();

		// Try to match against the path in a uri.  It returns the
		// code for the matched node (added using addURI), or -1 if
		// there is no matched node.  If a match occurs update the
		// appropriate rows.
		switch (sUriMatcher.match(uri)) {
			case ACRONYMS:
				// Begins a transaction in EXCLUSIVE mode.
				db.beginTransaction();
				int returnCount = 0;

				try {
					// TODOne -- write the code that inserts all the
					// contentValues into the SQLite database.
					for (ContentValues cv : contentValues) {
						long insert = db.insert(AcronymContract.AcronymEntry.TABLE_NAME, null, cv);
						if (insert != -1) {
							returnCount++;
						}
					}

					// Marks the current transaction as successful.
					db.setTransactionSuccessful();
				} finally {
					// End a transaction.
					db.endTransaction();
				}

				// Notifies registered observers that rows were updated.
				getContext().getContentResolver().notifyChange(uri, null);
				return returnCount;
			default:
				return super.bulkInsert(uri, contentValues);
		}
	}

	/**
	 * Hook method called to handle query requests from clients.
	 */
	@Override
	public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
		Cursor retCursor;
		SQLiteDatabase db = mOpenHelper.getWritableDatabase();

		// Match the id returned by UriMatcher to query appropriate
		// rows.
		switch (sUriMatcher.match(uri)) {
			case ACRONYMS:
				// TODOne -- replace "null" by writing code to query the
				// entire SQLite database based on the parameters passed
				// into the method.
				retCursor = db.query(AcronymContract.AcronymEntry.TABLE_NAME, projection, selection, selectionArgs, null, null, sortOrder);
				break;
			case ACRONYM:
				// Selection clause that matches row id with id passed
				// from Uri.
				final String rowId = "" + AcronymContract.AcronymEntry._ID + " = '" + ContentUris.parseId(uri) + "'";

				// TODOne -- replace "null" by writing code to query the
				// SQLite database for the particular rowId based on (a
				// subset of) the parameters passed into the method.
				retCursor = db.query(AcronymContract.AcronymEntry.TABLE_NAME, projection, rowId, null, null, null, sortOrder);
				break;
			default:
				throw new UnsupportedOperationException("Unknown uri: " + uri);
		}

		// Register to watch a content URI for changes.
		retCursor.setNotificationUri(getContext().getContentResolver(), uri);
		return retCursor;
	}

	/**
	 * Hook method called to handle requests to update one or more rows. The implementation should update all rows
	 * matching the selection to set the columns according to the provided values map. As a courtesy, notifyChange() is
	 * called after updating .
	 */
	@Override
	public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
		// Create and/or open a database that will be used for reading
		// and writing. Once opened successfully, the database is
		// cached, so you can call this method every time you need to
		// write to the database.
		final SQLiteDatabase db = mOpenHelper.getWritableDatabase();

		int rowsUpdated;

		// Try to match against the path in a uri.  It returns the
		// code for the matched node (added using addURI), or -1 if
		// there is no matched node.  If a match occurs update the
		// appropriate rows.
		switch (sUriMatcher.match(uri)) {
			case ACRONYMS:
				// Updates the rows in the Database and returns no of rows
				// updated.
				// TODOne -- replace "0" with a call to the SQLite database
				// to update the row(s) in the database based on the
				// parameters passed into this method.
				rowsUpdated = db.update(AcronymContract.AcronymEntry.TABLE_NAME, values, selection, selectionArgs);
				break;
			default:
				throw new UnsupportedOperationException("Unknown uri: " + uri);
		}

		// Notifies registered observers that rows were updated.
		if (rowsUpdated != 0) {
			getContext().getContentResolver().notifyChange(uri, null);
		}
		return rowsUpdated;
	}

	/**
	 * Hook method to handle requests to delete one or more rows. The implementation should apply the selection clause
	 * when performing deletion, allowing the operation to affect multiple rows in a directory. As a courtesy,
	 * notifyChange() is called after deleting.
	 */
	@Override
	public int delete(Uri uri, String selection, String[] selectionArgs) {
		// Create and/or open a database that will be used for reading
		// and writing. Once opened successfully, the database is
		// cached, so you can call this method every time you need to
		// write to the database.
		final SQLiteDatabase db = mOpenHelper.getWritableDatabase();

		// Keeps track of the number of rows deleted.
		int rowsDeleted = 0;

		// Try to match against the path in a url.  It returns the
		// code for the matched node (added using addURI) or -1 if
		// there is no matched node.  If a match is found delete the
		// appropriate rows.
		switch (sUriMatcher.match(uri)) {
			case ACRONYMS:
				// TODOne -- replace "0" with code that deletes the row(s)
				// in the SQLite database table based on the parameters
				// passed into the method.
				rowsDeleted = db.delete(AcronymContract.AcronymEntry.TABLE_NAME, selection, selectionArgs);
				break;
			default:
				throw new UnsupportedOperationException("Unknown uri: " + uri);
		}

		// Notifies registered observers that rows were deleted.
		if (selection == null || rowsDeleted != 0) {
			getContext().getContentResolver().notifyChange(uri, null);
		}
		return rowsDeleted;
	}
}


text:
<?php
namespace PayPal\Types\AA;
use PayPal\Core\PPMessage;
/**
 * Info about PayPal user such as emailAddress, accountId,
 * firstName, lastName etc.
 */
class UserInfoType
  extends PPMessage   {

	/**
	 * Returns emailAddress belonging to PayPal account.
	 * @access public

	 * @var string
	 */
	public $emailAddress;

	/**
	 * Valid values are: Personal, Premier, and Business (not
	 * case-sensitive).
	 * @access public

	 * @var string
	 */
	public $accountType;

	/**
	 * Identifies a PayPal account. Only premier and business
	 * accounts have an accountId
	 * @access public

	 * @var string
	 */
	public $accountId;

	/**
	 * Identifies a PayPal user, like firstName, lastName.
	 * @access public

	 * @var PayPal\Types\AA\NameType
	 */
	public $name;

	/**
	 * Business Name of the PayPal account holder.
	 * @access public

	 * @var string
	 */
	public $businessName;

}


text:
package org.bitcoins.core.protocol.dlc.build

import org.bitcoins.core.currency.Satoshis
import org.bitcoins.core.number.UInt64
import org.bitcoins.core.protocol.dlc.build.DLCTxBuilder.sortAndFilterOutputs
import org.bitcoins.core.protocol.dlc.models.{
  ContractInfo,
  DLCTimeouts,
  OracleOutcome
}
import org.bitcoins.core.protocol.script.{
  EmptyScriptSignature,
  MultiSignatureScriptPubKey,
  P2WSHWitnessV0,
  ScriptPubKey
}
import org.bitcoins.core.protocol.transaction._
import org.bitcoins.core.wallet.utxo.{
  ConditionalPath,
  InputInfo,
  P2WSHV0InputInfo
}
import org.bitcoins.crypto.ECPublicKey

/** Responsible for constructing unsigned
  * Contract Execution Transactions (CETs)
  */
case class DLCCETBuilder(
    contractInfo: ContractInfo,
    offerFundingKey: ECPublicKey,
    offerFinalSPK: ScriptPubKey,
    offerSerialId: UInt64,
    acceptFundingKey: ECPublicKey,
    acceptFinalSPK: ScriptPubKey,
    acceptSerialId: UInt64,
    timeouts: DLCTimeouts,
    fundingOutputRef: OutputReference) {

  private val fundingOutPoint = fundingOutputRef.outPoint

  private val fundingInput = TransactionInput(
    fundingOutPoint,
    EmptyScriptSignature,
    TransactionConstants.disableRBFSequence)

  private val fundingKeys =
    Vector(offerFundingKey, acceptFundingKey).sortBy(_.hex)

  private val fundingInfo = P2WSHV0InputInfo(
    outPoint = fundingOutPoint,
    amount = fundingOutputRef.output.value,
    scriptWitness = P2WSHWitnessV0(MultiSignatureScriptPubKey(2, fundingKeys)),
    conditionalPath = ConditionalPath.NoCondition
  )

  private val witnesses = Vector(InputInfo.getScriptWitness(fundingInfo))
  private val witness = TransactionWitness.fromWitOpt(witnesses)

  private def cetOfferOutput(offerValue: Satoshis): TransactionOutput = {
    TransactionOutput(offerValue, offerFinalSPK)
  }

  private def cetAcceptOutput(acceptValue: Satoshis): TransactionOutput = {
    TransactionOutput(acceptValue, acceptFinalSPK)
  }

  /** Constructs a Contract Execution Transaction (CET)
    * for a given outcome
    */
  def buildCET(outcome: OracleOutcome): WitnessTransaction = {
    val (offerPayout, acceptPayout) = contractInfo.getPayouts(outcome)

    val outputsWithSerialId =
      Vector((cetOfferOutput(offerPayout), offerSerialId),
             (cetAcceptOutput(acceptPayout), acceptSerialId))

    val outputs = sortAndFilterOutputs(outputsWithSerialId)

    WitnessTransaction(TransactionConstants.validLockVersion,
                       Vector(fundingInput),
                       outputs,
                       timeouts.contractMaturity.toUInt32,
                       witness)
  }
}