text:
package ca.mcgill.cs.sel.ram.impl;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.impl.EFactoryImpl;
import org.eclipse.emf.ecore.plugin.EcorePlugin;

import ca.mcgill.cs.sel.ram.Aspect;
import ca.mcgill.cs.sel.ram.AspectMessageView;
import ca.mcgill.cs.sel.ram.Association;
import ca.mcgill.cs.sel.ram.AssociationEnd;
import ca.mcgill.cs.sel.ram.Attribute;
import ca.mcgill.cs.sel.ram.AttributeMapping;
import ca.mcgill.cs.sel.ram.ClassifierMapping;
import ca.mcgill.cs.sel.ram.CombinedFragment;
import ca.mcgill.cs.sel.ram.Constraint;
import ca.mcgill.cs.sel.ram.DestructionOccurrenceSpecification;
import ca.mcgill.cs.sel.ram.ExecutionStatement;
import ca.mcgill.cs.sel.ram.Gate;
import ca.mcgill.cs.sel.ram.ImplementationClass;
import ca.mcgill.cs.sel.ram.Instantiation;
import ca.mcgill.cs.sel.ram.InstantiationType;
import ca.mcgill.cs.sel.ram.Interaction;
import ca.mcgill.cs.sel.ram.InteractionOperand;
import ca.mcgill.cs.sel.ram.InteractionOperatorKind;
import ca.mcgill.cs.sel.ram.Layout;
import ca.mcgill.cs.sel.ram.LayoutElement;
import ca.mcgill.cs.sel.ram.Lifeline;
import ca.mcgill.cs.sel.ram.LiteralBoolean;
import ca.mcgill.cs.sel.ram.LiteralInteger;
import ca.mcgill.cs.sel.ram.LiteralString;
import ca.mcgill.cs.sel.ram.Message;
import ca.mcgill.cs.sel.ram.MessageOccurrenceSpecification;
import ca.mcgill.cs.sel.ram.MessageSort;
import ca.mcgill.cs.sel.ram.MessageView;
import ca.mcgill.cs.sel.ram.MessageViewReference;
import ca.mcgill.cs.sel.ram.OccurrenceSpecification;
import ca.mcgill.cs.sel.ram.OpaqueExpression;
import ca.mcgill.cs.sel.ram.Operation;
import ca.mcgill.cs.sel.ram.OperationMapping;
import ca.mcgill.cs.sel.ram.OriginalBehaviorExecution;
import ca.mcgill.cs.sel.ram.Parameter;
import ca.mcgill.cs.sel.ram.ParameterMapping;
import ca.mcgill.cs.sel.ram.ParameterValue;
import ca.mcgill.cs.sel.ram.ParameterValueMapping;
import ca.mcgill.cs.sel.ram.RAny;
import ca.mcgill.cs.sel.ram.RArray;
import ca.mcgill.cs.sel.ram.RBoolean;
import ca.mcgill.cs.sel.ram.RChar;
import ca.mcgill.cs.sel.ram.RDouble;
import ca.mcgill.cs.sel.ram.REnum;
import ca.mcgill.cs.sel.ram.REnumLiteral;
import ca.mcgill.cs.sel.ram.RFloat;
import ca.mcgill.cs.sel.ram.RInt;
import ca.mcgill.cs.sel.ram.RLong;
import ca.mcgill.cs.sel.ram.RSequence;
import ca.mcgill.cs.sel.ram.RSet;
import ca.mcgill.cs.sel.ram.RString;
import ca.mcgill.cs.sel.ram.RVoid;
import ca.mcgill.cs.sel.ram.RamFactory;
import ca.mcgill.cs.sel.ram.RamPackage;
import ca.mcgill.cs.sel.ram.Reference;
import ca.mcgill.cs.sel.ram.ReferenceType;
import ca.mcgill.cs.sel.ram.State;
import ca.mcgill.cs.sel.ram.StateMachine;
import ca.mcgill.cs.sel.ram.StateView;
import ca.mcgill.cs.sel.ram.StructuralFeatureValue;
import ca.mcgill.cs.sel.ram.StructuralView;
import ca.mcgill.cs.sel.ram.Substitution;
import ca.mcgill.cs.sel.ram.Transition;
import ca.mcgill.cs.sel.ram.TransitionSubstitution;
import ca.mcgill.cs.sel.ram.TypeParameter;
import ca.mcgill.cs.sel.ram.Visibility;
import java.util.Map;
import org.eclipse.emf.common.util.EMap;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model <b>Factory</b>.
 * <!-- end-user-doc -->
 * @generated
 */
public class RamFactoryImpl extends EFactoryImpl implements RamFactory {
	/**
     * Creates the default factory implementation.
     * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
     * @generated
     */
	public static RamFactory init() {
        try {
            RamFactory theRamFactory = (RamFactory)EPackage.Registry.INSTANCE.getEFactory(RamPackage.eNS_URI);
            if (theRamFactory != null) {
                return theRamFactory;
            }
        }
        catch (Exception exception) {
            EcorePlugin.INSTANCE.log(exception);
        }
        return new RamFactoryImpl();
    }

	/**
     * Creates an instance of the factory.
     * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
     * @generated
     */
	public RamFactoryImpl() {
        super();
    }

	/**
     * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
     * @generated
     */
	@Override
	public EObject create(EClass eClass) {
        switch (eClass.getClassifierID()) {
            case RamPackage.ASPECT: return createAspect();
            case RamPackage.STRUCTURAL_VIEW: return createStructuralView();
            case RamPackage.CLASS: return createClass();
            case RamPackage.ASSOCIATION_END: return createAssociationEnd();
            case RamPackage.ASSOCIATION: return createAssociation();
            case RamPackage.INSTANTIATION: return createInstantiation();
            case RamPackage.OPERATION: return createOperation();
            case RamPackage.ATTRIBUTE: return createAttribute();
            case RamPackage.PARAMETER: return createParameter();
            case RamPackage.RVOID: return createRVoid();
            case RamPackage.RBOOLEAN: return createRBoolean();
            case RamPackage.RINT: return createRInt();
            case RamPackage.RCHAR: return createRChar();
            case RamPackage.RSTRING: return createRString();
            case RamPackage.RANY: return createRAny();
            case RamPackage.RENUM: return createREnum();
            case RamPackage.RENUM_LITERAL: return createREnumLiteral();
            case RamPackage.MESSAGE_VIEW: return createMessageView();
            case RamPackage.MESSAGE_VIEW_REFERENCE: return createMessageViewReference();
            case RamPackage.INTERACTION: return createInteraction();
            case RamPackage.ASPECT_MESSAGE_VIEW: return createAspectMessageView();
            case RamPackage.LIFELINE: return createLifeline();
            case RamPackage.MESSAGE: return createMessage();
            case RamPackage.MESSAGE_OCCURRENCE_SPECIFICATION: return createMessageOccurrenceSpecification();
            case RamPackage.OCCURRENCE_SPECIFICATION: return createOccurrenceSpecification();
            case RamPackage.DESTRUCTION_OCCURRENCE_SPECIFICATION: return createDestructionOccurrenceSpecification();
            case RamPackage.COMBINED_FRAGMENT: return createCombinedFragment();
            case RamPackage.ORIGINAL_BEHAVIOR_EXECUTION: return createOriginalBehaviorExecution();
            case RamPackage.EXECUTION_STATEMENT: return createExecutionStatement();
            case RamPackage.INTERACTION_OPERAND: return createInteractionOperand();
            case RamPackage.STRUCTURAL_FEATURE_VALUE: return createStructuralFeatureValue();
            case RamPackage.PARAMETER_VALUE_MAPPING: return createParameterValueMapping();
            case RamPackage.PARAMETER_VALUE: return createParameterValue();
            case RamPackage.OPAQUE_EXPRESSION: return createOpaqueExpression();
            case RamPackage.LITERAL_STRING: return createLiteralString();
            case RamPackage.LITERAL_INTEGER: return createLiteralInteger();
            case RamPackage.RSET: return createRSet();
            case RamPackage.RSEQUENCE: return createRSequence();
            case RamPackage.LAYOUT: return createLayout();
            case RamPackage.CONTAINER_MAP: return (EObject)createContainerMap();
            case RamPackage.ELEMENT_MAP: return (EObject)createElementMap();
            case RamPackage.LAYOUT_ELEMENT: return createLayoutElement();
            case RamPackage.IMPLEMENTATION_CLASS: return createImplementationClass();
            case RamPackage.REFERENCE: return createReference();
            case RamPackage.GATE: return createGate();
            case RamPackage.LITERAL_BOOLEAN: return createLiteralBoolean();
            case RamPackage.CLASSIFIER_MAPPING: return createClassifierMapping();
            case RamPackage.ATTRIBUTE_MAPPING: return createAttributeMapping();
            case RamPackage.OPERATION_MAPPING: return createOperationMapping();
            case RamPackage.PARAMETER_MAPPING: return createParameterMapping();
            case RamPackage.STATE_VIEW: return createStateView();
            case RamPackage.STATE_MACHINE: return createStateMachine();
            case RamPackage.TRANSITION: return createTransition();
            case RamPackage.STATE: return createState();
            case RamPackage.RDOUBLE: return createRDouble();
            case RamPackage.RFLOAT: return createRFloat();
            case RamPackage.CONSTRAINT: return createConstraint();
            case RamPackage.SUBSTITUTION: return createSubstitution();
            case RamPackage.TRANSITION_SUBSTITUTION: return createTransitionSubstitution();
            case RamPackage.TYPE_PARAMETER: return createTypeParameter();
            case RamPackage.RLONG: return createRLong();
            case RamPackage.RARRAY: return createRArray();
            default:
                throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
        }
    }

	/**
     * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
     * @generated
     */
	@Override
	public Object createFromString(EDataType eDataType, String initialValue) {
        switch (eDataType.getClassifierID()) {
            case RamPackage.VISIBILITY:
                return createVisibilityFromString(eDataType, initialValue);
            case RamPackage.REFERENCE_TYPE:
                return createReferenceTypeFromString(eDataType, initialValue);
            case RamPackage.MESSAGE_SORT:
                return createMessageSortFromString(eDataType, initialValue);
            case RamPackage.INTERACTION_OPERATOR_KIND:
                return createInteractionOperatorKindFromString(eDataType, initialValue);
            case RamPackage.INSTANTIATION_TYPE:
                return createInstantiationTypeFromString(eDataType, initialValue);
            default:
                throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
        }
    }

	/**
     * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
     * @generated
     */
	@Override
	public String convertToString(EDataType eDataType, Object instanceValue) {
        switch (eDataType.getClassifierID()) {
            case RamPackage.VISIBILITY:
                return convertVisibilityToString(eDataType, instanceValue);
            case RamPackage.REFERENCE_TYPE:
                return convertReferenceTypeToString(eDataType, instanceValue);
            case RamPackage.MESSAGE_SORT:
                return convertMessageSortToString(eDataType, instanceValue);
            case RamPackage.INTERACTION_OPERATOR_KIND:
                return convertInteractionOperatorKindToString(eDataType, instanceValue);
            case RamPackage.INSTANTIATION_TYPE:
                return convertInstantiationTypeToString(eDataType, instanceValue);
            default:
                throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
        }
    }

	/**
     * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
     * @generated
     */
	public Aspect createAspect() {
        AspectImpl aspect = new AspectImpl();
        return aspect;
    }

	/**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public StructuralView createStructuralView() {
        StructuralViewImpl structuralView = new StructuralViewImpl();
        return structuralView;
    }

    /**
     * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
     * @generated
     */
	public ca.mcgill.cs.sel.ram.Class createClass() {
        ClassImpl class_ = new ClassImpl();
        return class_;
    }

	/**
     * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
     * @generated
     */
	public AssociationEnd createAssociationEnd() {
        AssociationEndImpl associationEnd = new AssociationEndImpl();
        return associationEnd;
    }

	/**
     * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
     * @generated
     */
	public Association createAssociation() {
        AssociationImpl association = new AssociationImpl();
        return association;
    }

	/**
     * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
     * @generated
     */
	public Instantiation createInstantiation() {
        InstantiationImpl instantiation = new InstantiationImpl();
        return instantiation;
    }

	/**
     * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
     * @generated
     */
	public Operation createOperation() {
        OperationImpl operation = new OperationImpl();
        return operation;
    }

	/**
     * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
     * @generated
     */
	public Attribute createAttribute() {
        AttributeImpl attribute = new AttributeImpl();
        return attribute;
    }

	/**
     * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
     * @generated
     */
	public Parameter createParameter() {
        ParameterImpl parameter = new ParameterImpl();
        return parameter;
    }

	/**
     * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
     * @generated
     */
	public RVoid createRVoid() {
        RVoidImpl rVoid = new RVoidImpl();
        return rVoid;
    }

	/**
     * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
     * @generated
     */
	public RBoolean createRBoolean() {
        RBooleanImpl rBoolean = new RBooleanImpl();
        return rBoolean;
    }

	/**
     * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
     * @generated
     */
	public RInt createRInt() {
        RIntImpl rInt = new RIntImpl();
        return rInt;
    }

	/**
     * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
     * @generated
     */
	public RChar createRChar() {
        RCharImpl rChar = new RCharImpl();
        return rChar;
    }

	/**
     * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
     * @generated
     */
	public RString createRString() {
        RStringImpl rString = new RStringImpl();
        return rString;
    }

	/**
     * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
     * @generated
     */
	public RAny createRAny() {
        RAnyImpl rAny = new RAnyImpl();
        return rAny;
    }

	/**
     * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
     * @generated
     */
	public REnum createREnum() {
        REnumImpl rEnum = new REnumImpl();
        return rEnum;
    }

	/**
     * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
     * @generated
     */
	public REnumLiteral createREnumLiteral() {
        REnumLiteralImpl rEnumLiteral = new REnumLiteralImpl();
        return rEnumLiteral;
    }

	/**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public MessageView createMessageView() {
        MessageViewImpl messageView = new MessageViewImpl();
        return messageView;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public MessageViewReference createMessageViewReference() {
        MessageViewReferenceImpl messageViewReference = new MessageViewReferenceImpl();
        return messageViewReference;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public Interaction createInteraction() {
        InteractionImpl interaction = new InteractionImpl();
        return interaction;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public AspectMessageView createAspectMessageView() {
        AspectMessageViewImpl aspectMessageView = new AspectMessageViewImpl();
        return aspectMessageView;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public Lifeline createLifeline() {
        LifelineImpl lifeline = new LifelineImpl();
        return lifeline;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public Message createMessage() {
        MessageImpl message = new MessageImpl();
        return message;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public MessageOccurrenceSpecification createMessageOccurrenceSpecification() {
        MessageOccurrenceSpecificationImpl messageOccurrenceSpecification = new MessageOccurrenceSpecificationImpl();
        return messageOccurrenceSpecification;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public OccurrenceSpecification createOccurrenceSpecification() {
        OccurrenceSpecificationImpl occurrenceSpecification = new OccurrenceSpecificationImpl();
        return occurrenceSpecification;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public DestructionOccurrenceSpecification createDestructionOccurrenceSpecification() {
        DestructionOccurrenceSpecificationImpl destructionOccurrenceSpecification = new DestructionOccurrenceSpecificationImpl();
        return destructionOccurrenceSpecification;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public CombinedFragment createCombinedFragment() {
        CombinedFragmentImpl combinedFragment = new CombinedFragmentImpl();
        return combinedFragment;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public OriginalBehaviorExecution createOriginalBehaviorExecution() {
        OriginalBehaviorExecutionImpl originalBehaviorExecution = new OriginalBehaviorExecutionImpl();
        return originalBehaviorExecution;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public ExecutionStatement createExecutionStatement() {
        ExecutionStatementImpl executionStatement = new ExecutionStatementImpl();
        return executionStatement;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public InteractionOperand createInteractionOperand() {
        InteractionOperandImpl interactionOperand = new InteractionOperandImpl();
        return interactionOperand;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public StructuralFeatureValue createStructuralFeatureValue() {
        StructuralFeatureValueImpl structuralFeatureValue = new StructuralFeatureValueImpl();
        return structuralFeatureValue;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public ParameterValueMapping createParameterValueMapping() {
        ParameterValueMappingImpl parameterValueMapping = new ParameterValueMappingImpl();
        return parameterValueMapping;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public ParameterValue createParameterValue() {
        ParameterValueImpl parameterValue = new ParameterValueImpl();
        return parameterValue;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public OpaqueExpression createOpaqueExpression() {
        OpaqueExpressionImpl opaqueExpression = new OpaqueExpressionImpl();
        return opaqueExpression;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public LiteralString createLiteralString() {
        LiteralStringImpl literalString = new LiteralStringImpl();
        return literalString;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public LiteralInteger createLiteralInteger() {
        LiteralIntegerImpl literalInteger = new LiteralIntegerImpl();
        return literalInteger;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public RSet createRSet() {
        RSetImpl rSet = new RSetImpl();
        return rSet;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public RSequence createRSequence() {
        RSequenceImpl rSequence = new RSequenceImpl();
        return rSequence;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public Layout createLayout() {
        LayoutImpl layout = new LayoutImpl();
        return layout;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public Map.Entry<EObject, EMap<EObject, LayoutElement>> createContainerMap() {
        ContainerMapImpl containerMap = new ContainerMapImpl();
        return containerMap;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public Map.Entry<EObject, LayoutElement> createElementMap() {
        ElementMapImpl elementMap = new ElementMapImpl();
        return elementMap;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public LayoutElement createLayoutElement() {
        LayoutElementImpl layoutElement = new LayoutElementImpl();
        return layoutElement;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public ImplementationClass createImplementationClass() {
        ImplementationClassImpl implementationClass = new ImplementationClassImpl();
        return implementationClass;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public Reference createReference() {
        ReferenceImpl reference = new ReferenceImpl();
        return reference;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public Gate createGate() {
        GateImpl gate = new GateImpl();
        return gate;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public LiteralBoolean createLiteralBoolean() {
        LiteralBooleanImpl literalBoolean = new LiteralBooleanImpl();
        return literalBoolean;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public ClassifierMapping createClassifierMapping() {
        ClassifierMappingImpl classifierMapping = new ClassifierMappingImpl();
        return classifierMapping;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public AttributeMapping createAttributeMapping() {
        AttributeMappingImpl attributeMapping = new AttributeMappingImpl();
        return attributeMapping;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public OperationMapping createOperationMapping() {
        OperationMappingImpl operationMapping = new OperationMappingImpl();
        return operationMapping;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public ParameterMapping createParameterMapping() {
        ParameterMappingImpl parameterMapping = new ParameterMappingImpl();
        return parameterMapping;
    }

    /**
     * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
     * @generated
     */
	public StateView createStateView() {
        StateViewImpl stateView = new StateViewImpl();
        return stateView;
    }

				/**
     * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
     * @generated
     */
	public StateMachine createStateMachine() {
        StateMachineImpl stateMachine = new StateMachineImpl();
        return stateMachine;
    }

				/**
     * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
     * @generated
     */
	public Transition createTransition() {
        TransitionImpl transition = new TransitionImpl();
        return transition;
    }

				/**
     * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
     * @generated
     */
	public State createState() {
        StateImpl state = new StateImpl();
        return state;
    }

				/**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public RDouble createRDouble() {
        RDoubleImpl rDouble = new RDoubleImpl();
        return rDouble;
    }

                /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public RFloat createRFloat() {
        RFloatImpl rFloat = new RFloatImpl();
        return rFloat;
    }

                /**
     * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
     * @generated
     */
	public Constraint createConstraint() {
        ConstraintImpl constraint = new ConstraintImpl();
        return constraint;
    }

																/**
     * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
     * @generated
     */
	public Substitution createSubstitution() {
        SubstitutionImpl substitution = new SubstitutionImpl();
        return substitution;
    }

																/**
     * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
     * @generated
     */
	public TransitionSubstitution createTransitionSubstitution() {
        TransitionSubstitutionImpl transitionSubstitution = new TransitionSubstitutionImpl();
        return transitionSubstitution;
    }

																/**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public TypeParameter createTypeParameter() {
        TypeParameterImpl typeParameter = new TypeParameterImpl();
        return typeParameter;
    }

                                                                /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public RLong createRLong() {
        RLongImpl rLong = new RLongImpl();
        return rLong;
    }

                                                                /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public RArray createRArray() {
        RArrayImpl rArray = new RArrayImpl();
        return rArray;
    }

                                                                /**
     * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
     * @generated
     */
	public Visibility createVisibilityFromString(EDataType eDataType, String initialValue) {
        Visibility result = Visibility.get(initialValue);
        if (result == null) throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'");
        return result;
    }

	/**
     * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
     * @generated
     */
	public String convertVisibilityToString(EDataType eDataType, Object instanceValue) {
        return instanceValue == null ? null : instanceValue.toString();
    }

	/**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public ReferenceType createReferenceTypeFromString(EDataType eDataType, String initialValue) {
        ReferenceType result = ReferenceType.get(initialValue);
        if (result == null) throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'");
        return result;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public String convertReferenceTypeToString(EDataType eDataType, Object instanceValue) {
        return instanceValue == null ? null : instanceValue.toString();
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public MessageSort createMessageSortFromString(EDataType eDataType, String initialValue) {
        MessageSort result = MessageSort.get(initialValue);
        if (result == null) throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'");
        return result;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public String convertMessageSortToString(EDataType eDataType, Object instanceValue) {
        return instanceValue == null ? null : instanceValue.toString();
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public InteractionOperatorKind createInteractionOperatorKindFromString(EDataType eDataType, String initialValue) {
        InteractionOperatorKind result = InteractionOperatorKind.get(initialValue);
        if (result == null) throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'");
        return result;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public String convertInteractionOperatorKindToString(EDataType eDataType, Object instanceValue) {
        return instanceValue == null ? null : instanceValue.toString();
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public InstantiationType createInstantiationTypeFromString(EDataType eDataType, String initialValue) {
        InstantiationType result = InstantiationType.get(initialValue);
        if (result == null) throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'");
        return result;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public String convertInstantiationTypeToString(EDataType eDataType, Object instanceValue) {
        return instanceValue == null ? null : instanceValue.toString();
    }

    /**
     * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
     * @generated
     */
	public RamPackage getRamPackage() {
        return (RamPackage)getEPackage();
    }

	/**
     * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
     * @deprecated
     * @generated
     */
	@Deprecated
	public static RamPackage getPackage() {
        return RamPackage.eINSTANCE;
    }

} //RamFactoryImpl


text:
class AzEmployeesController < ApplicationController

  filter_access_to :all

  layout "main"

  # GET /az_employees
  # GET /az_employees.xml
  def index
    @az_employees = AzEmployee.all

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @az_employees }
    end
  end

  # GET /index_user
  def index_user

    @me = current_user
    @my_companies = current_user.az_companies
    @employees = AzEmployee.get_by_companies(@my_companies)

    @title = 'Работники'

    respond_to do |format|
      format.html # index.html.erb
    end
  end

#  # GET /az_employees/1
#  # GET /az_employees/1.xml
#  def show
#    @az_employee = AzEmployee.find(params[:id])
#
#    respond_to do |format|
#      format.html # show.html.erb
#      format.xml  { render :xml => @az_employee }
#    end
#  end
#
  # GET /az_employees/new
  # GET /az_employees/new.xml
#  def new
#    @az_employee = AzEmployee.new
#
#    respond_to do |format|
#      format.html # new.html.erb
#      format.xml  { render :xml => @az_employee }
#    end
#  end
#
#  # GET /az_employees/1/edit
#  def edit
#    @az_employee = AzEmployee.find(params[:id])
#  end
#
#  # POST /az_employees
#  # POST /az_employees.xml
#  def create
#    @az_employee = AzEmployee.new(params[:az_employee])
#
#    respond_to do |format|
#      if @az_employee.save
#        flash[:notice] = 'AzEmployee was successfully created.'
#        format.html { redirect_to(@az_employee) }
#        format.xml  { render :xml => @az_employee, :status => :created, :location => @az_employee }
#      else
#        format.html { render :action => "new" }
#        format.xml  { render :xml => @az_employee.errors, :status => :unprocessable_entity }
#      end
#    end
#  end
#
#  # PUT /az_employees/1
#  # PUT /az_employees/1.xml
#  def update
#    @az_employee = AzEmployee.find(params[:id])
#
#    respond_to do |format|
#      if @az_employee.update_attributes(params[:az_employee])
#        flash[:notice] = 'AzEmployee was successfully updated.'
#        format.html { redirect_to(@az_employee) }
#        format.xml  { head :ok }
#      else
#        format.html { render :action => "edit" }
#        format.xml  { render :xml => @az_employee.errors, :status => :unprocessable_entity }
#      end
#    end
#  end

  # DELETE /az_employees/1
  # DELETE /az_employees/1.xml
  # def destroy
  #   employee = AzEmployee.find(params[:id])
  #   employee.az_company.delete_employee1(employee)

  #   respond_to do |format|
  #     format.html { redirect_to(:action => 'index_user') }
  #   end
  # end

  def dismiss
    employee = AzEmployee.find(params[:id])
    employee.az_company.delete_employee(employee)

    respond_to do |format|
      format.html { redirect_to(:action => 'index_user') }
    end
  end

  def enable
    @az_employee = AzEmployee.find(params[:id])
    @az_employee.enable

    respond_to do |format|
      format.html { redirect_to(:action => 'index_user') }
    end
  end

  def disable
    @az_employee = AzEmployee.find(params[:id])
    @az_employee.disable

    respond_to do |format|
      format.html { redirect_to(:action => 'index_user') }
    end
  end
end

redpajama_set_name: RedPajamaGithub


text:
require 'torznab/client/caps/mappers/search_modes_mapper'
require 'torznab/client/caps/mappers/categories_mapper'
require 'torznab/client/caps/instance'
require 'torznab/client/errors/xml_error'
require 'nokogiri'

module Torznab
  module Client
    module Caps
      module Mappers
        # Instance of caps mapper
        module InstanceMapper
          class << self
            # Map the data from a Nokogiri::XML::Element to an Instance object
            # corresponding of the caps node of the caps xml
            #
            # @param [Nokogiri::XML::Element] xml_element data from a caps node to map
            # @return [Torznab::Client::Caps::Instance] Mapped Caps instance
            # @raise [Torznab::Client::Errors::XmlError]
            def map(xml_element)
              unless xml_element.is_a? Nokogiri::XML::Element
                raise XmlError, 'Provided object is not a Nokogiri::XML::Element'
              end

              caps = Torznab::Client::Caps::Instance.new
              caps.search_modes = map_search_modes xml_element
              caps.categories = map_categories xml_element
              caps
            end

            private

            def map_search_modes(xml_element)
              node_searching = xml_element.at 'searching'
              raise XmlError, 'Searching node must be defined' if node_searching.nil?
              SearchModesMapper.map node_searching
            end

            def map_categories(xml_element)
              node_categories = xml_element.at 'categories'
              raise XmlError, 'Categories node must be defined' if node_categories.nil?
              CategoriesMapper.map node_categories
            end

            XmlError = Torznab::Client::Errors::XmlError
          end
        end
      end
    end
  end
end


text:
<?php

namespace APY\DataGridBundle\Grid\Action;

interface RowActionInterface
{
    /**
     * get action title
     *
     * @return string
     */
    public function getTitle();

    /**
     * get action route
     *
     * @return string
     */
    public function getRoute();

    /**
     * get action confirm
     *
     * @return boolean
     */
    public function getConfirm();

    /**
     * get action confirmMessage
     *
     * @return boolean
     */
    public function getConfirmMessage();

    /**
     * get action target
     *
     * @return boolean
     */
    public function getTarget();

    /**
     * get the action column id
     *
     * @return boolean
     */
    public function getColumn();

    /**
     * get route parameters
     *
     * @return array
     */
    public function getRouteParameters();

    /**
     * get attributes of the link
     *
     * @return array
     */
    public function getAttributes();

    /**
     * get action enabled
     *
     * @return boolean
     */
    public function getEnabled();
}


text:
#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_VR_IS_READY_REQUEST_H_
#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_VR_IS_READY_REQUEST_H_

#include "application_manager/commands/hmi/request_to_hmi.h"
#include "application_manager/message_helper.h"

namespace application_manager {

namespace commands {

/**
 * @brief VRIsReadyRequest command class
 **/
class VRIsReadyRequest : public RequestToHMI,
                         public event_engine::EventObserver {
 public:
  /**
   * @brief VRIsReadyRequest class constructor
   *
   * @param message Incoming SmartObject message
   **/
  VRIsReadyRequest(const MessageSharedPtr& message,
                   ApplicationManager& application_manager);

  /**
   * @brief VRIsReadyRequest class destructor
   **/
  virtual ~VRIsReadyRequest();

  /**
   * @brief Execute command
   **/
  void Run() OVERRIDE;

  /**
   * @brief On event callback
   **/
  void on_event(const event_engine::Event& event) OVERRIDE;

  /**
   * @brief onTimeOut from requrst Controller
   */
  void onTimeOut() OVERRIDE;

  /**
   * @brief Send request to HMI for fetching of cappabilities
   */
  void SendMessageToHMI();

 private:
  DISALLOW_COPY_AND_ASSIGN(VRIsReadyRequest);
};

}  // namespace commands

}  // namespace application_manager

#endif  // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_VR_IS_READY_REQUEST_H_


text:
// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: google/ads/googleads/v12/services/conversion_custom_variable_service.proto

package com.google.ads.googleads.v12.services;

public interface MutateConversionCustomVariableResultOrBuilder extends
    // @@protoc_insertion_point(interface_extends:google.ads.googleads.v12.services.MutateConversionCustomVariableResult)
    com.google.protobuf.MessageOrBuilder {

  /**
   *

   * Returned for successful operations.
   *

   *
   * string resource_name = 1 [(.google.api.resource_reference) = { ... }
   * @return The resourceName.
   */
  java.lang.String getResourceName();
  /**
   *

   * Returned for successful operations.
   *

   *
   * string resource_name = 1 [(.google.api.resource_reference) = { ... }
   * @return The bytes for resourceName.
   */
  com.google.protobuf.ByteString
      getResourceNameBytes();

  /**
   *

   * The mutated conversion custom variable with only mutable fields after
   * mutate. The field will only be returned when response_content_type is set
   * to "MUTABLE_RESOURCE".
   *

   *
   * .google.ads.googleads.v12.resources.ConversionCustomVariable conversion_custom_variable = 2;
   * @return Whether the conversionCustomVariable field is set.
   */
  boolean hasConversionCustomVariable();
  /**
   *

   * The mutated conversion custom variable with only mutable fields after
   * mutate. The field will only be returned when response_content_type is set
   * to "MUTABLE_RESOURCE".
   *

   *
   * .google.ads.googleads.v12.resources.ConversionCustomVariable conversion_custom_variable = 2;
   * @return The conversionCustomVariable.
   */
  com.google.ads.googleads.v12.resources.ConversionCustomVariable getConversionCustomVariable();
  /**
   *

   * The mutated conversion custom variable with only mutable fields after
   * mutate. The field will only be returned when response_content_type is set
   * to "MUTABLE_RESOURCE".
   *

   *
   * .google.ads.googleads.v12.resources.ConversionCustomVariable conversion_custom_variable = 2;
   */
  com.google.ads.googleads.v12.resources.ConversionCustomVariableOrBuilder getConversionCustomVariableOrBuilder();
}


text:
title: How to use Jest to test Express middleware or a function which consumes a callback?
date: 2017-06-10 12:58:28
tags:
  - jest
  - test
  - javascript
  - express
---

Jest's document says that you could use `done` as a parameter to test a function which takes a callback function as a parameter, but is it really the answer to every case? Sometimes, errors in your assertion in your callback will yield a timeout with meaningless call stack. I happened to solve a problem with a different approach. The solution here is not only apply to express middleware, but also to any function which consumes a callback.

## 1. A simple middleware which generate a JSON Web Token.

```javascript
const issueJWT = (req, res, next) => {
  const signUser = {
    id: res.locals.user._id.toString()
  };

  jwt.sign(
    signUser,
    "HS256KEY",
    { expiresIn: "120days", algorithm: "HS256" },
    (err, token) => {
      if (err) {
        return next(err);
      }
      res.locals.token = token;
      next();
    }
  );
};
```

The middleware is simple, just uses id and some key to generate a JWT, invoke error handler if there is an error.

## 2. This is the test.

```javascript
test("Should return a JWT with proper value if nothing wrong happened", done => {
  const callback = err => {
    const JWT = response.locals.token;
    const tokenPayload = jwt.decode(JWT, { complete: true }).payload;

    expect(err).toBeFalsy();
    expect(tokenPayload).toHaveProperty("iat");
    expect(tokenPayload).toHaveProperty("exp");
    expect(tokenPayload).toHaveProperty("id");
    expect(tokenPayload).toHaveProperty("iss");
    done();
  };

  issueJWT(request, response, callback);
});
```

Is it pass? Yes, of course, and I actually use breakpoint to check it indeed invoked the callback function. And this is the way which follows the official documents said.

## 3. So, it works, what's the problem?

The problem is, when you have an error, you won't see a clear answer. The error message is like this:

> ● Test issueJWT › Should return a JWT with proper value if nothing wrong happened
>
> Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
>
>      at pTimeout (node_modules/jest-jasmine2/build/queueRunner.js:53:21)
>      at Timeout.callback [as _onTimeout] (node_modules/jsdom/lib/jsdom/browser/Window.js:523:19)
>      at ontimeout (timers.js:380:14)
>      at tryOnTimeout (timers.js:244:5)
>      at Timer.listOnTimeout (timers.js:214:5)

OMG, this is something we don't want.

## 4. The solution.

The final solution is to wrap the logic inside a Promise.

```javascript
test("Should return a JWT with proper value if nothing wrong happened", () => {
  return new Promise(resolve => {
    issueJWT(request, response, err => {
      if (!err) {
        resolve(response.locals.token);
      }
    });
  }).then(result => {
    const tokenPayload = jwt.decode(result, { complete: true }).payload;

    expect(tokenPayload).toHaveProperty("iat");
    expect(tokenPayload).toHaveProperty("exp");
    expect(tokenPayload).toHaveProperty("id");
    expect(tokenPayload).toHaveProperty("iss");
  });
});
```

This time, when there is an error. You will get a meaningful stack and message.

> ● Test issueJWT › Should return a JWT with proper value if nothing wrong happened
>
> expect(object).toHaveProperty(path)
>
> Expected the object:
> {"exp": 1507424033, "iat": 1497056033, "id": "5935240e5d8761601b691137"}
>
> To have a nested property:
> "iat1"
>
>      at tests/backend/unit/fblogin/issueJWT.test.js:48:34
>      at tryCatcher (node_modules/bluebird/js/release/util.js:16:23)

## 5. Use async / await to make it clear

The above solution may seems too heavy. But you can use `async / await` to make it a little bit concise.

```javascript
test("Should return a JWT with proper value if nothing wrong happened", async () => {
  const result = await new Promise(resolve => {
    issueJWT(request, response, err => {
      if (!err) {
        resolve(response.locals.token);
      }
    });
  });

  const tokenPayload = jwt.decode(result, { complete: true }).payload;

  expect(tokenPayload).toHaveProperty("iat");
  expect(tokenPayload).toHaveProperty("exp");
  expect(tokenPayload).toHaveProperty("id");
  expect(tokenPayload).toHaveProperty("iss");
});
```

## 6. End of story.

A rule of thumb is, whenever your test pass, try to make it fail then check. :)

Thanks for reading!

Follow me (albertgao) on twitter, if you want to hear more about my interesting ideas.


text:
<?php
/**
 * StatusCallbackData Class as Eloquent Model
 *
 * @author rutoru
 * @package Runa-CCA
 */
namespace Runa_CCA\Model\Database;

class StatusCallbackData extends \Illuminate\Database\Eloquent\Model{

/*
CREATE TABLE statuscallback_data
(
	`CallSid` CHAR(34) PRIMARY KEY NOT NULL UNIQUE,
	`From` VARCHAR(255),
	`To` VARCHAR(255),
	`CallStatus` VARCHAR(15),
	`ApiVersion` CHAR(10),
	`Direction` VARCHAR(15),
	`ForwardedFrom` VARCHAR(255),
	`CallerName` VARCHAR(255),
	`CallDuration` INT,
	`RecordingUrl` VARCHAR(255),
	`RecordingSid` CHAR(34),
        `RecordingDuration` INT,
        `updated_at` DATETIME,
        `created_at` DATETIME,
         INDEX cst_idx(CallStatus),
         INDEX rsid_idx(RecordingSid)
)
ENGINE InnoDB;
 */

    public $table = 'statuscallback_data';
    public $primaryKey = 'CallSid';
    //public $timestamps = false;
    protected $fillable =   [
                                'CallSid',
                                'From',
                                'To',
                                'CallStatus',
                                'ApiVersion',
                                'Direction',
                                'ForwardedFrom',
                                'CallerName',
                                'CallDuration',
                                'RecordingUrl',
                                'RecordingSid',
                                'RecordingDuration',
                            ];

}


text:
package org.drools.beliefs.bayes.weaver;

import org.drools.beliefs.bayes.assembler.BayesPackage;
import org.drools.core.definitions.InternalKnowledgePackage;
import org.kie.api.KieBase;
import org.kie.api.definition.KiePackage;
import org.kie.api.io.ResourceType;
import org.kie.internal.io.ResourceTypePackage;
import org.kie.internal.weaver.KieWeaverService;

import java.util.Map;

public class BayesWeaverService implements KieWeaverService<BayesPackage> {

    public BayesWeaverService() {

    }

    @Override
    public Class getServiceInterface() {
        return KieWeaverService.class;
    }

    @Override
    public ResourceType getResourceType() {
        return ResourceType.BAYES;
    }

    @Override
    public void merge(KieBase kieBase, KiePackage kiePkg, BayesPackage bayesPkg) {
        Map<ResourceType, ResourceTypePackage> map = ((InternalKnowledgePackage)kiePkg).getResourceTypePackages();
        BayesPackage existing  = (BayesPackage) map.get( ResourceType.BAYES );
        if ( existing == null ) {
            existing = new BayesPackage();
            map.put(ResourceType.BAYES, existing);
        }

        for ( String name : bayesPkg.listJunctionTrees() ) {
            existing.addJunctionTree( name, bayesPkg.getJunctionTree( name ) );
        }
    }

    @Override
    public void weave(KieBase kieBase, KiePackage kiePkg, BayesPackage rtPkg) {
        System.out.println( "Hello World " );
    }

}


text:
using System;
using System.Collections.Generic;
using System.Linq;
using Windows.UI.ApplicationSettings;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;

namespace PizzaMapPoint.Helper
{
    public partial class SettingsHelper
    {
        private Popup m_Popup = new Popup();
        private readonly List<ICommandInfo> Commands = new List<ICommandInfo>();

        public SettingsHelper()
        {
            SettingsPane.GetForCurrentView().CommandsRequested += (s, e) =>
            {
                foreach (var item in Commands)
                {
                    var _Command = new SettingsCommand(item.Key, item.Text,
                        c => { Show(item.Instance(), item.Width); });
                    e.Request.ApplicationCommands.Add(_Command);
                }
            };
        }

        public void AddCommand<T>(string text, string key = null,
            PanelWidths width = PanelWidths.Small) where T : UserControl, new()
        {
            CommandInfo<T> cmd =
                new CommandInfo<T>()
                {
                    Key = key ?? text,
                    Text = text,
                    Width = (int)width
                };

            if (null == this.Commands.FirstOrDefault(c => c.Key.Equals(cmd.Key)))
                this.Commands.Add(cmd);
        }

        private Popup Show(UserControl control, double width)
        {
            if (control == null)
                throw new Exception("Control is not defined");
            if (double.IsNaN(width))
                throw new Exception("Width is not defined");

            // layout
            m_Popup.Width = width;
            m_Popup.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Right;
            m_Popup.Height = Window.Current.Bounds.Height;
            m_Popup.SetValue(Canvas.LeftProperty, Window.Current.Bounds.Width - m_Popup.Width);

            // make content fit
            m_Popup.Child = control;
            control.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Stretch;
            control.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Stretch;
            control.Height = m_Popup.Height;
            control.Width = m_Popup.Width;

            // add pretty animation(s)
            m_Popup.ChildTransitions = new Windows.UI.Xaml.Media.Animation.TransitionCollection
            {
                new Windows.UI.Xaml.Media.Animation.EntranceThemeTransition
                {
                    FromHorizontalOffset = 20d,
                    FromVerticalOffset = 0d
                }
            };

            // setup
            m_Popup.IsLightDismissEnabled = true;
            m_Popup.IsOpen = true;

            // handle when it closes
            m_Popup.Closed -= popup_Closed;
            m_Popup.Closed += popup_Closed;

            // handle making it close
            Window.Current.Activated -= Current_Activated;
            Window.Current.Activated += Current_Activated;

            // return
            return m_Popup;
        }

        private void Current_Activated(object sender, Windows.UI.Core.WindowActivatedEventArgs e)
        {
            if (m_Popup == null)
                return;
            if (e.WindowActivationState == Windows.UI.Core.CoreWindowActivationState.Deactivated)
                m_Popup.IsOpen = false;
        }

        private void popup_Closed(object sender, object e)
        {
            Window.Current.Activated -= Current_Activated;
            if (m_Popup == null)
                return;
            m_Popup.IsOpen = false;
        }

        private interface ICommandInfo
        {
            string Key { get; set; }

            string Text { get; set; }

            double Width { get; set; }

            UserControl Instance();
        }

        private class CommandInfo<T> : ICommandInfo where T : UserControl, new()
        {
            public string Key { get; set; }

            public string Text { get; set; }

            public double Width { get; set; }

            public UserControl Instance()
            {
                return new T();
            }
        }

        public enum PanelWidths : int
        {
            Small = 346,
            Large = 646
        }
    }
}


text:
package org.javacore.io.byteoper;

/**
 * @author admin
 * @since 2015-6-19 21:25:57
 * 	Integer类的进制转换
 */
public class IntegerOperT {

	public static void main(String[] args) {
		System.out.println("17的十六进制: " + Integer.toHexString(17));
		System.out.println("17的八进制:     " 	+ Integer.toOctalString(17));
		System.out.println("17的二进制:     " 	+ Integer.toBinaryString(17));

		System.out.println(Integer.valueOf("11", 16));
		System.out.println(Integer.valueOf("21", 8));
		System.out.println(Integer.valueOf("00010001", 2));
	}

}


text:
.class final Lcom/android/internal/policy/impl/PhoneWindow$DialogMenuCallback;
.super Ljava/lang/Object;
.source "PhoneWindow.java"

# interfaces
.implements Lcom/android/internal/view/menu/MenuBuilder$Callback;
.implements Lcom/android/internal/view/menu/MenuPresenter$Callback;

# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Lcom/android/internal/policy/impl/PhoneWindow;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x12
    name = "DialogMenuCallback"
.end annotation

# instance fields
.field private mFeatureId:I

.field private mSubMenuHelper:Lcom/android/internal/view/menu/MenuDialogHelper;

.field final synthetic this$0:Lcom/android/internal/policy/impl/PhoneWindow;

# direct methods
.method public constructor <init>(Lcom/android/internal/policy/impl/PhoneWindow;I)V
    .locals 0
    .parameter
    .parameter "featureId"

    .prologue
    .line 3845
    iput-object p1, p0, Lcom/android/internal/policy/impl/PhoneWindow$DialogMenuCallback;->this$0:Lcom/android/internal/policy/impl/PhoneWindow;

    invoke-direct/range {p0 .. p0}, Ljava/lang/Object;-><init>()V

    .line 3846
    iput p2, p0, Lcom/android/internal/policy/impl/PhoneWindow$DialogMenuCallback;->mFeatureId:I

    .line 3847
    return-void
.end method

# virtual methods
.method public onCloseMenu(Lcom/android/internal/view/menu/MenuBuilder;Z)V
    .locals 2
    .parameter "menu"
    .parameter "allMenusAreClosing"

    .prologue
    .line 3850
    invoke-virtual {p1}, Lcom/android/internal/view/menu/MenuBuilder;->getRootMenu()Lcom/android/internal/view/menu/MenuBuilder;

    move-result-object v1

    if-eq v1, p1, :cond_0

    .line 3851
    invoke-virtual {p0, p1}, Lcom/android/internal/policy/impl/PhoneWindow$DialogMenuCallback;->onCloseSubMenu(Lcom/android/internal/view/menu/MenuBuilder;)V

    .line 3854
    :cond_0
    if-eqz p2, :cond_3

    .line 3855
    iget-object v1, p0, Lcom/android/internal/policy/impl/PhoneWindow$DialogMenuCallback;->this$0:Lcom/android/internal/policy/impl/PhoneWindow;

    invoke-virtual {v1}, Lcom/android/internal/policy/impl/PhoneWindow;->getCallback()Landroid/view/Window$Callback;

    move-result-object v0

    .line 3856
    .local v0, callback:Landroid/view/Window$Callback;
    if-eqz v0, :cond_1

    iget-object v1, p0, Lcom/android/internal/policy/impl/PhoneWindow$DialogMenuCallback;->this$0:Lcom/android/internal/policy/impl/PhoneWindow;

    invoke-virtual {v1}, Lcom/android/internal/policy/impl/PhoneWindow;->isDestroyed()Z

    move-result v1

    if-nez v1, :cond_1

    .line 3857
    iget v1, p0, Lcom/android/internal/policy/impl/PhoneWindow$DialogMenuCallback;->mFeatureId:I

    invoke-interface {v0, v1, p1}, Landroid/view/Window$Callback;->onPanelClosed(ILandroid/view/Menu;)V

    .line 3860
    :cond_1
    iget-object v1, p0, Lcom/android/internal/policy/impl/PhoneWindow$DialogMenuCallback;->this$0:Lcom/android/internal/policy/impl/PhoneWindow;

    #getter for: Lcom/android/internal/policy/impl/PhoneWindow;->mContextMenu:Lcom/android/internal/view/menu/ContextMenuBuilder;
    invoke-static {v1}, Lcom/android/internal/policy/impl/PhoneWindow;->access$1000(Lcom/android/internal/policy/impl/PhoneWindow;)Lcom/android/internal/view/menu/ContextMenuBuilder;

    move-result-object v1

    if-ne p1, v1, :cond_2

    .line 3861
    iget-object v1, p0, Lcom/android/internal/policy/impl/PhoneWindow$DialogMenuCallback;->this$0:Lcom/android/internal/policy/impl/PhoneWindow;

    #calls: Lcom/android/internal/policy/impl/PhoneWindow;->dismissContextMenu()V
    invoke-static {v1}, Lcom/android/internal/policy/impl/PhoneWindow;->access$2100(Lcom/android/internal/policy/impl/PhoneWindow;)V

    .line 3865
    :cond_2
    iget-object v1, p0, Lcom/android/internal/policy/impl/PhoneWindow$DialogMenuCallback;->mSubMenuHelper:Lcom/android/internal/view/menu/MenuDialogHelper;

    if-eqz v1, :cond_3

    .line 3866
    iget-object v1, p0, Lcom/android/internal/policy/impl/PhoneWindow$DialogMenuCallback;->mSubMenuHelper:Lcom/android/internal/view/menu/MenuDialogHelper;

    invoke-virtual {v1}, Lcom/android/internal/view/menu/MenuDialogHelper;->dismiss()V

    .line 3867
    const/4 v1, 0x0

    iput-object v1, p0, Lcom/android/internal/policy/impl/PhoneWindow$DialogMenuCallback;->mSubMenuHelper:Lcom/android/internal/view/menu/MenuDialogHelper;

    .line 3870
    .end local v0           #callback:Landroid/view/Window$Callback;
    :cond_3
    return-void
.end method

.method public onCloseSubMenu(Lcom/android/internal/view/menu/MenuBuilder;)V
    .locals 3
    .parameter "menu"

    .prologue
    .line 3873
    iget-object v1, p0, Lcom/android/internal/policy/impl/PhoneWindow$DialogMenuCallback;->this$0:Lcom/android/internal/policy/impl/PhoneWindow;

    invoke-virtual {v1}, Lcom/android/internal/policy/impl/PhoneWindow;->getCallback()Landroid/view/Window$Callback;

    move-result-object v0

    .line 3874
    .local v0, callback:Landroid/view/Window$Callback;
    if-eqz v0, :cond_0

    iget-object v1, p0, Lcom/android/internal/policy/impl/PhoneWindow$DialogMenuCallback;->this$0:Lcom/android/internal/policy/impl/PhoneWindow;

    invoke-virtual {v1}, Lcom/android/internal/policy/impl/PhoneWindow;->isDestroyed()Z

    move-result v1

    if-nez v1, :cond_0

    .line 3875
    iget v1, p0, Lcom/android/internal/policy/impl/PhoneWindow$DialogMenuCallback;->mFeatureId:I

    invoke-virtual {p1}, Lcom/android/internal/view/menu/MenuBuilder;->getRootMenu()Lcom/android/internal/view/menu/MenuBuilder;

    move-result-object v2

    invoke-interface {v0, v1, v2}, Landroid/view/Window$Callback;->onPanelClosed(ILandroid/view/Menu;)V

    .line 3877
    :cond_0
    return-void
.end method

.method public onMenuItemSelected(Lcom/android/internal/view/menu/MenuBuilder;Landroid/view/MenuItem;)Z
    .locals 2
    .parameter "menu"
    .parameter "item"

    .prologue
    .line 3880
    iget-object v1, p0, Lcom/android/internal/policy/impl/PhoneWindow$DialogMenuCallback;->this$0:Lcom/android/internal/policy/impl/PhoneWindow;

    invoke-virtual {v1}, Lcom/android/internal/policy/impl/PhoneWindow;->getCallback()Landroid/view/Window$Callback;

    move-result-object v0

    .line 3881
    .local v0, callback:Landroid/view/Window$Callback;
    if-eqz v0, :cond_0

    iget-object v1, p0, Lcom/android/internal/policy/impl/PhoneWindow$DialogMenuCallback;->this$0:Lcom/android/internal/policy/impl/PhoneWindow;

    invoke-virtual {v1}, Lcom/android/internal/policy/impl/PhoneWindow;->isDestroyed()Z

    move-result v1

    if-nez v1, :cond_0

    iget v1, p0, Lcom/android/internal/policy/impl/PhoneWindow$DialogMenuCallback;->mFeatureId:I

    invoke-interface {v0, v1, p2}, Landroid/view/Window$Callback;->onMenuItemSelected(ILandroid/view/MenuItem;)Z

    move-result v1

    if-eqz v1, :cond_0

    const/4 v1, 0x1

    :goto_0
    return v1

    :cond_0
    const/4 v1, 0x0

    goto :goto_0
.end method

.method public onMenuModeChange(Lcom/android/internal/view/menu/MenuBuilder;)V
    .locals 0
    .parameter "menu"

    .prologue
    .line 3886
    return-void
.end method

.method public onOpenSubMenu(Lcom/android/internal/view/menu/MenuBuilder;)Z
    .locals 2
    .parameter "subMenu"

    .prologue
    .line 3889
    if-nez p1, :cond_0

    const/4 v0, 0x0

    .line 3898
    :goto_0
    return v0

    .line 3892
    :cond_0
    invoke-virtual {p1, p0}, Lcom/android/internal/view/menu/MenuBuilder;->setCallback(Lcom/android/internal/view/menu/MenuBuilder$Callback;)V

    .line 3895
    new-instance v0, Lcom/android/internal/view/menu/MenuDialogHelper;

    invoke-direct {v0, p1}, Lcom/android/internal/view/menu/MenuDialogHelper;-><init>(Lcom/android/internal/view/menu/MenuBuilder;)V

    iput-object v0, p0, Lcom/android/internal/policy/impl/PhoneWindow$DialogMenuCallback;->mSubMenuHelper:Lcom/android/internal/view/menu/MenuDialogHelper;

    .line 3896
    iget-object v0, p0, Lcom/android/internal/policy/impl/PhoneWindow$DialogMenuCallback;->mSubMenuHelper:Lcom/android/internal/view/menu/MenuDialogHelper;

    const/4 v1, 0x0

    invoke-virtual {v0, v1}, Lcom/android/internal/view/menu/MenuDialogHelper;->show(Landroid/os/IBinder;)V

    .line 3898
    const/4 v0, 0x1

    goto :goto_0
.end method


text:
using blink::WebContextMenuData;
using content::WebContents;

#if defined(ENABLE_EXTENSIONS)
using extensions::Extension;
using extensions::ProcessManager;
#endif

namespace {

bool IsDevToolsURL(const GURL& url) {
  return url.SchemeIs(content::kChromeDevToolsScheme);
}

bool DefaultIsInternalResourcesURL(const GURL& url) {
  return url.SchemeIs(content::kChromeUIScheme);
}

}  // namespace

ContextMenuContentType::ContextMenuContentType(
    content::WebContents* web_contents,
    const content::ContextMenuParams& params,
    bool supports_custom_items)
    : params_(params),
      source_web_contents_(web_contents),
      supports_custom_items_(supports_custom_items),
      internal_resources_url_checker_(
          base::Bind(&DefaultIsInternalResourcesURL)) {
}

ContextMenuContentType::~ContextMenuContentType() {
}

#if defined(ENABLE_EXTENSIONS)
const Extension* ContextMenuContentType::GetExtension() const {
  ProcessManager* process_manager =
      ProcessManager::Get(source_web_contents_->GetBrowserContext());
  return process_manager->GetExtensionForRenderViewHost(
      source_web_contents_->GetRenderViewHost());
}
#endif

bool ContextMenuContentType::SupportsGroup(int group) {
  const bool has_selection = !params_.selection_text.empty();

  if (supports_custom_items_ && !params_.custom_items.empty()) {
    if (group == ITEM_GROUP_CUSTOM)
      return true;

    if (!has_selection) {
      // For menus with custom items, if there is no selection, we do not
      // add items other than developer items. And for Pepper menu, don't even
      // add developer items.
      if (!params_.custom_context.is_pepper_menu)
        return group == ITEM_GROUP_DEVELOPER;

      return false;
    }

    // If there's a selection when there are custom items, fall through to
    // adding the normal ones after the custom ones.
  }

  if (IsDevToolsURL(params_.page_url)) {
    // DevTools mostly provides custom context menu and uses
    // only the following default options.
    if (group != ITEM_GROUP_CUSTOM &&
        group != ITEM_GROUP_EDITABLE &&
        group != ITEM_GROUP_COPY &&
        group != ITEM_GROUP_DEVELOPER) {
      return false;
    }
  }

  return SupportsGroupInternal(group);
}

bool ContextMenuContentType::SupportsGroupInternal(int group) {
  const bool has_link = !params_.unfiltered_link_url.is_empty();
  const bool has_selection = !params_.selection_text.empty();

  switch (group) {
    case ITEM_GROUP_CUSTOM:
      return supports_custom_items_ && !params_.custom_items.empty();

    case ITEM_GROUP_PAGE: {
      bool is_candidate =
          params_.media_type == WebContextMenuData::MediaTypeNone &&
          !has_link && !params_.is_editable && !has_selection;

      if (!is_candidate && params_.page_url.is_empty())
        DCHECK(params_.frame_url.is_empty());

      return is_candidate && !params_.page_url.is_empty() &&
          !IsInternalResourcesURL(params_.page_url);
    }

    case ITEM_GROUP_FRAME: {
      bool page_group_supported = SupportsGroupInternal(ITEM_GROUP_PAGE);
      return page_group_supported && !params_.frame_url.is_empty() &&
          !IsInternalResourcesURL(params_.page_url);
    }

    case ITEM_GROUP_LINK:
      return has_link;

    case ITEM_GROUP_MEDIA_IMAGE:
      return params_.media_type == WebContextMenuData::MediaTypeImage;

    case ITEM_GROUP_SEARCHWEBFORIMAGE:
      // Image menu items imply search web for image item.
      return SupportsGroupInternal(ITEM_GROUP_MEDIA_IMAGE);

    case ITEM_GROUP_MEDIA_VIDEO:
      return params_.media_type == WebContextMenuData::MediaTypeVideo;

    case ITEM_GROUP_MEDIA_AUDIO:
      return params_.media_type == WebContextMenuData::MediaTypeAudio;

    case ITEM_GROUP_MEDIA_CANVAS:
      return params_.media_type == WebContextMenuData::MediaTypeCanvas;

    case ITEM_GROUP_MEDIA_PLUGIN:
      return params_.media_type == WebContextMenuData::MediaTypePlugin;

    case ITEM_GROUP_MEDIA_FILE:
#if defined(WEBCONTEXT_MEDIATYPEFILE_DEFINED)
      return params_.media_type == WebContextMenuData::MediaTypeFile;
#else
      return false;
#endif

    case ITEM_GROUP_EDITABLE:
      return params_.is_editable;

    case ITEM_GROUP_COPY:
      return !params_.is_editable && has_selection;

    case ITEM_GROUP_SEARCH_PROVIDER:
      return has_selection;

    case ITEM_GROUP_PRINT: {
      // Image menu items also imply print items.
      return has_selection || SupportsGroupInternal(ITEM_GROUP_MEDIA_IMAGE);
    }

    case ITEM_GROUP_ALL_EXTENSION:
      return true;

    case ITEM_GROUP_CURRENT_EXTENSION:
      return false;

    case ITEM_GROUP_DEVELOPER:
      return true;

    case ITEM_GROUP_DEVTOOLS_UNPACKED_EXT:
      return false;

    case ITEM_GROUP_PRINT_PREVIEW:
#if defined(ENABLE_PRINT_PREVIEW)
      return true;
#else
      return false;
#endif

    default:
      NOTREACHED();
      return false;
  }
}

bool ContextMenuContentType::IsInternalResourcesURL(const GURL& url) {
  return internal_resources_url_checker_.Run(url);
}


text:
package de.qaware.chronix.solr.compaction;

import org.apache.lucene.document.Document;
import org.apache.lucene.search.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.util.Iterator;

/**
 * Loads documents lazily from solr when {@link Iterator#next()} is called.
 * Documents are loaded in pages and not scores computed.
 * <p>
 * Use this class if you want to efficiently iterate over large result sets.
 *
 * @author alex.christ
 */
public class LazyDocumentLoader {
    private static final Logger LOGGER = LoggerFactory.getLogger(LazyDocumentLoader.class);
    private final int pageLimit;

    /**
     * Creates a new instance.
     *
     * @param pageLimit the number of documents to be loaded into memory at a time.
     */
    public LazyDocumentLoader(int pageLimit) {
        this.pageLimit = pageLimit;
    }

    /**
     * Loads documents sorted in index order.
     *
     * @param searcher the index searcher
     * @param query    the query
     * @param sort     the sort criterion
     * @return found documents
     */
    public Iterable<Document> load(IndexSearcher searcher, Query query, Sort sort) {
        return new LazySolrDocumentSet(searcher, query, sort);
    }

    private final class LazySolrDocumentSet implements Iterator<Document>, Iterable<Document> {
        private final IndexSearcher searcher;
        private Query query;
        private Sort sort;
        private ScoreDoc[] page;
        private int pageHitsRead;

        private LazySolrDocumentSet(IndexSearcher searcher, Query query, Sort sort) {
            this.searcher = searcher;
            this.query = query;
            this.sort = sort;
            try {
                TopDocs topDocs = searcher.searchAfter(null, query, pageLimit, sort);
                page = topDocs.scoreDocs;
                pageHitsRead = 0;
            } catch (IOException e) {
                LOGGER.error("Could not retrieve documents", e);
            }
        }

        @Override
        public boolean hasNext() {
            return page.length > 0;
        }

        @Override
        public Document next() {
            Document result;
            try {
                result = searcher.doc(page[pageHitsRead].doc);
                pageHitsRead++;
                if (pageHitsRead == page.length) {
                    ScoreDoc lastDoc = page[page.length - 1];
                    page = searcher.searchAfter(lastDoc, query, pageLimit, sort).scoreDocs;
                    pageHitsRead = 0;
                }
            } catch (IOException e) {
                LOGGER.error("Could not retrieve documents", e);
                return null;
            }
            return result;
        }

        @Override
        public Iterator<Document> iterator() {
            return this;
        }
    }
}


text:
<?php

namespace Flarum\Filesystem;

use Flarum\Foundation\Config;
use Flarum\Settings\SettingsRepositoryInterface;
use Illuminate\Contracts\Filesystem\Cloud;

interface DriverInterface
{
    /**
     * Construct a Laravel Cloud filesystem for this filesystem driver.
     * Settings and configuration can either be pulled from the Flarum settings repository
     * or the config.php file.
     *
     * Typically, this is done by wrapping a Flysystem adapter in Laravel's
     * `Illuminate\Filesystem\FilesystemAdapter` class.
     * You should ensure that the Flysystem adapter you use has a `getUrl` method.
     * If it doesn't, you should create a subclass implementing that method.
     * Otherwise, this driver won't work for public-facing disks
     * like `flarum-assets` or `flarum-avatars`.
     *
     * @param string $diskName: The name of a disk this driver is being used for.
     *                   This is generally used to locate disk-specific settings.
     * @param SettingsRepositoryInterface $settings: An instance of the Flarum settings repository.
     * @param Config $config: An instance of the wrapper class around `config.php`.
     * @param array $localConfig: The configuration array that would have been used
     *                            if this disk were using the 'local' filesystem driver.
     *                            Some of these settings might be useful (e.g. visibility, )
     */
    public function build(string $diskName, SettingsRepositoryInterface $settings, Config $config, array $localConfig): Cloud;
}


text:
"""
    This module provides the Argument-Expression Registry
"""

from singleton import singleton

from .exceptions import RadishError

@singleton()
class ArgExpRegistry(object):
    """
        Registry for all custom argument expressions
    """
    def __init__(self):
        self._expressions = {}

    def register(self, name, func):
        """
            Registers a custom argument expression
        """
        if name in self._expressions:
            raise RadishError("Cannot register argument expression with name {0} because it already exists".format(name))

        self._expressions[name] = func

    @property
    def expressions(self):
        """
            Returns all registered expressions
        """
        return self._expressions

def arg_expr(name, expression):
    """
        Decorator for custom argument expressions
    """
    def _decorator(func):
        """
            Actual decorator
        """
        func.pattern = expression
        ArgExpRegistry().register(name, func)

        return func
    return _decorator


text:
package org.r4d5.teamcity.todo.common;

import java.io.Serializable;
import java.nio.charset.Charset;
import java.nio.file.Path;

public class TodoScanResult implements Serializable {

    // stable serialization
    private static final long serialVersionUID = 7114331626146889652L;

    final String relativePath;
    final String charsetName;
    final long runTime;
    final TodoLine[] todos;

    public TodoScanResult(Path relativeFile, Charset charset, long runTime, TodoLine[] todos) {
        this.relativePath = relativeFile.toString();
        this.charsetName = charset.name();
        this.runTime = runTime;
        this.todos = todos;
    }

    public String getFilePath() {
        return relativePath;
    }

    public String getCharsetName() {
        return charsetName;
    }

    public Charset getCharset() {
        return Charset.forName(charsetName);
    }

    public TodoLine[] getTodos() {
        return todos;
    }

    public long getRunTime() {
        return runTime;
    }
}


text:
package pl.tomaszdziurko.jvm_bloggers.people;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import pl.tomaszdziurko.jvm_bloggers.TimeConstants;

@Component
@Slf4j
public class BloggersDataFetchingScheduler {

    private BloggersDataFetcher bloggersDataFetcher;

    @Autowired
    public BloggersDataFetchingScheduler(BloggersDataFetcher bloggersDataFetcher) {
        this.bloggersDataFetcher = bloggersDataFetcher;
    }

    @Scheduled(fixedRate = TimeConstants.THIRTY_MINUTES)
    public void fetchBloggersData() {
        log.info("Starting scheduler: bloggers data refresh");
        bloggersDataFetcher.refreshData();
    }
}