text:
//
//  ALView+PureLayout.m
//  v2.0.0
//  https://github.com/smileyborg/PureLayout
//
//  Copyright (c) 2012 Richard Turton
//  Copyright (c) 2013-2014 Tyler Fox
//
//  This code is distributed under the terms and conditions of the MIT license.
//
//  Permission is hereby granted, free of charge, to any person obtaining a copy
//  of this software and associated documentation files (the "Software"), to
//  deal in the Software without restriction, including without limitation the
//  rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
//  sell copies of the Software, and to permit persons to whom the Software is
//  furnished to do so, subject to the following conditions:
//
//  The above copyright notice and this permission notice shall be included in
//  all copies or substantial portions of the Software.
//
//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
//  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
//  IN THE SOFTWARE.
//

#import "ALView+PureLayout.h"
#import "NSLayoutConstraint+PureLayout.h"
#import "NSArray+PureLayout.h"
#import "PureLayout+Internal.h"

#pragma mark - ALView+PureLayout

@implementation ALView (PureLayout)

#pragma mark Factory & Initializer Methods

/**
 Creates and returns a new view that does not convert the autoresizing mask into constraints.
 */
+ (instancetype)newAutoLayoutView
{
    ALView *view = [self new];
    view.translatesAutoresizingMaskIntoConstraints = NO;
    return view;
}

/**
 Initializes and returns a new view that does not convert the autoresizing mask into constraints.
 */
- (instancetype)initForAutoLayout
{
    self = [self init];
    if (self) {
        self.translatesAutoresizingMaskIntoConstraints = NO;
    }
    return self;
}

#pragma mark Create Constraints Without Installing

/**
 A global variable that is set to YES while the constraints block passed in to the
 +[autoCreateConstraintsWithoutInstalling:] method is executing.
 NOTE: Access to this variable is not synchronized (and should only be done on the main thread).
 */
static BOOL _al_preventAutomaticConstraintInstallation = NO;

/**
 Public accessor for the global variable that determines whether automatic constraint installation should be prevented.
 */
+ (BOOL)al_preventAutomaticConstraintInstallation
{
    return _al_preventAutomaticConstraintInstallation;
}

/**
 Prevents constraints created in the given constraints block from being automatically installed (activated).
 The created constraints returned from each PureLayout API call must be stored, as they are not retained.

 @param block A block of method calls to the PureLayout API that create constraints.
 */
+ (void)autoCreateConstraintsWithoutInstalling:(ALConstraintsBlock)block
{
    NSAssert(block, @"The constraints block cannot be nil.");
    if (block) {
        _al_preventAutomaticConstraintInstallation = YES;
        block();
        _al_preventAutomaticConstraintInstallation = NO;
    }
}

#pragma mark Set Priority For Constraints

/**
 A global variable that determines the priority of all constraints created and added by this category.
 Defaults to Required, will only be a different value while executing a constraints block passed into the
 +[autoSetPriority:forConstraints:] method (as that method will reset the value back to Required
 before returning).
 NOTE: Access to this variable is not synchronized (and should only be done on the main thread).
 */
static ALLayoutPriority _al_globalConstraintPriority = ALLayoutPriorityRequired;

/**
 A global variable that is set to YES while the constraints block passed in to the
 +[autoSetPriority:forConstraints:] method is executing.
 NOTE: Access to this variable is not synchronized (and should only be done on the main thread).
 */
static BOOL _al_isExecutingConstraintsBlock = NO;

/**
 Sets the constraint priority to the given value for all constraints created using the PureLayout
 API within the given constraints block.

 NOTE: This method will have no effect (and will NOT set the priority) on constraints created or added
 using the SDK directly within the block!

 @param priority The layout priority to be set on all constraints in the constraints block.
 @param block A block of method calls to the PureLayout API that create and install constraints.
 */
+ (void)autoSetPriority:(ALLayoutPriority)priority forConstraints:(ALConstraintsBlock)block
{
    NSAssert(block, @"The constraints block cannot be nil.");
    if (block) {
        _al_globalConstraintPriority = priority;
        _al_isExecutingConstraintsBlock = YES;
        block();
        _al_isExecutingConstraintsBlock = NO;
        _al_globalConstraintPriority = ALLayoutPriorityRequired;
    }
}

#pragma mark Remove Constraints

/**
 Removes all explicit constraints that affect the view.
 WARNING: Apple's constraint solver is not optimized for large-scale constraint removal; you may encounter major performance issues after using this method.
          It is not recommended to use this method to "reset" a view for reuse in a different way with new constraints. Create a new view instead.
 NOTE: This method preserves implicit constraints, such as intrinsic content size constraints, which you usually do not want to remove.
 */
- (void)autoRemoveConstraintsAffectingView
{
    [self autoRemoveConstraintsAffectingViewIncludingImplicitConstraints:NO];
}

/**
 Removes all constraints that affect the view, optionally including implicit constraints.
 WARNING: Apple's constraint solver is not optimized for large-scale constraint removal; you may encounter major performance issues after using this method.
          It is not recommended to use this method to "reset" a view for reuse in a different way with new constraints. Create a new view instead.
 NOTE: Implicit constraints are auto-generated lower priority constraints (such as those that attempt to keep a view at
 its intrinsic content size by hugging its content & resisting compression), and you usually do not want to remove these.

 @param shouldRemoveImplicitConstraints Whether implicit constraints should be removed or skipped.
 */
- (void)autoRemoveConstraintsAffectingViewIncludingImplicitConstraints:(BOOL)shouldRemoveImplicitConstraints
{
    NSMutableArray *constraintsToRemove = [NSMutableArray new];
    ALView *startView = self;
    do {
        for (NSLayoutConstraint *constraint in startView.constraints) {
            BOOL isImplicitConstraint = [NSStringFromClass([constraint class]) isEqualToString:@"NSContentSizeLayoutConstraint"];
            if (shouldRemoveImplicitConstraints || !isImplicitConstraint) {
                if (constraint.firstItem == self || constraint.secondItem == self) {
                    [constraintsToRemove addObject:constraint];
                }
            }
        }
        startView = startView.superview;
    } while (startView);
    [constraintsToRemove autoRemoveConstraints];
}

/**
 Recursively removes all explicit constraints that affect the view and its subviews.
 WARNING: Apple's constraint solver is not optimized for large-scale constraint removal; you may encounter major performance issues after using this method.
          It is not recommended to use this method to "reset" views for reuse in a different way with new constraints. Create a new view instead.
 NOTE: This method preserves implicit constraints, such as intrinsic content size constraints, which you usually do not want to remove.
 */
- (void)autoRemoveConstraintsAffectingViewAndSubviews
{
    [self autoRemoveConstraintsAffectingViewAndSubviewsIncludingImplicitConstraints:NO];
}

/**
 Recursively removes all constraints that affect the view and its subviews, optionally including implicit constraints.
 WARNING: Apple's constraint solver is not optimized for large-scale constraint removal; you may encounter major performance issues after using this method.
          It is not recommended to use this method to "reset" views for reuse in a different way with new constraints. Create a new view instead.
 NOTE: Implicit constraints are auto-generated lower priority constraints (such as those that attempt to keep a view at
 its intrinsic content size by hugging its content & resisting compression), and you usually do not want to remove these.

 @param shouldRemoveImplicitConstraints Whether implicit constraints should be removed or skipped.
 */
- (void)autoRemoveConstraintsAffectingViewAndSubviewsIncludingImplicitConstraints:(BOOL)shouldRemoveImplicitConstraints
{
    [self autoRemoveConstraintsAffectingViewIncludingImplicitConstraints:shouldRemoveImplicitConstraints];
    for (ALView *subview in self.subviews) {
        [subview autoRemoveConstraintsAffectingViewAndSubviewsIncludingImplicitConstraints:shouldRemoveImplicitConstraints];
    }
}

#pragma mark Center in Superview

/**
 Centers the view in its superview.

 @return An array of constraints added.
 */
- (NSArray *)autoCenterInSuperview
{
    NSMutableArray *constraints = [NSMutableArray new];
    [constraints addObject:[self autoAlignAxisToSuperviewAxis:ALAxisHorizontal]];
    [constraints addObject:[self autoAlignAxisToSuperviewAxis:ALAxisVertical]];
    return constraints;
}

/**
 Aligns the view to the same axis of its superview.

 @param axis The axis of this view and of its superview to align.
 @return The constraint added.
 */
- (NSLayoutConstraint *)autoAlignAxisToSuperviewAxis:(ALAxis)axis
{
    self.translatesAutoresizingMaskIntoConstraints = NO;
    ALView *superview = self.superview;
    NSAssert(superview, @"View's superview must not be nil.\nView: %@", self);
    return [self autoConstrainAttribute:axis toAttribute:axis ofView:superview];
}

#if __PureLayout_MinBaseSDK_iOS8

/**
 Centers the view in its superview, taking into account the layout margins of both the view and its superview.

 @return An array of constraints added.
 */
- (NSArray *)autoCenterInSuperviewMargins
{
    NSMutableArray *constraints = [NSMutableArray new];
    [constraints addObject:[self autoAlignAxisToSuperviewMarginAxis:ALAxisHorizontal]];
    [constraints addObject:[self autoAlignAxisToSuperviewMarginAxis:ALAxisVertical]];
    return constraints;
}

/**
 Aligns the view to the corresponding margin axis of its superview.

 @param axis The axis of this view to align to the corresponding margin axis of its superview.
 @return The constraint added.
 */
- (NSLayoutConstraint *)autoAlignAxisToSuperviewMarginAxis:(ALAxis)axis
{
    self.translatesAutoresizingMaskIntoConstraints = NO;
    ALView *superview = self.superview;
    NSAssert(superview, @"View's superview must not be nil.\nView: %@", self);
    ALMarginAxis marginAxis = [NSLayoutConstraint al_marginAxisForAxis:axis];
    return [self autoConstrainAttribute:axis toAttribute:marginAxis ofView:superview];
}

#endif /* __PureLayout_MinBaseSDK_iOS8 */

#pragma mark Pin Edges to Superview

/**
 Pins the given edge of the view to the same edge of its superview.

 @param edge The edge of this view and its superview to pin.
 @return The constraint added.
 */
- (NSLayoutConstraint *)autoPinEdgeToSuperviewEdge:(ALEdge)edge
{
    return [self autoPinEdgeToSuperviewEdge:edge withInset:0.0];
}

/**
 Pins the given edge of the view to the same edge of its superview with an inset.

 @param edge The edge of this view and its superview to pin.
 @param inset The amount to inset this view's edge from the superview's edge.
 @return The constraint added.
 */
- (NSLayoutConstraint *)autoPinEdgeToSuperviewEdge:(ALEdge)edge withInset:(CGFloat)inset
{
    return [self autoPinEdgeToSuperviewEdge:edge withInset:inset relation:NSLayoutRelationEqual];
}

/**
 Pins the given edge of the view to the same edge of its superview with an inset as a maximum or minimum.

 @param edge The edge of this view and its superview to pin.
 @param inset The amount to inset this view's edge from the superview's edge.
 @param relation Whether the inset should be at least, at most, or exactly equal to the given value.
 @return The constraint added.
 */
- (NSLayoutConstraint *)autoPinEdgeToSuperviewEdge:(ALEdge)edge withInset:(CGFloat)inset relation:(NSLayoutRelation)relation
{
    self.translatesAutoresizingMaskIntoConstraints = NO;
    ALView *superview = self.superview;
    NSAssert(superview, @"View's superview must not be nil.\nView: %@", self);
    if (edge == ALEdgeBottom || edge == ALEdgeRight || edge == ALEdgeTrailing) {
        // The bottom, right, and trailing insets (and relations, if an inequality) are inverted to become offsets
        inset = -inset;
        if (relation == NSLayoutRelationLessThanOrEqual) {
            relation = NSLayoutRelationGreaterThanOrEqual;
        } else if (relation == NSLayoutRelationGreaterThanOrEqual) {
            relation = NSLayoutRelationLessThanOrEqual;
        }
    }
    return [self autoPinEdge:edge toEdge:edge ofView:superview withOffset:inset relation:relation];
}

/**
 Pins the edges of the view to the edges of its superview with the given edge insets.
 The insets.left corresponds to a leading edge constraint, and insets.right corresponds to a trailing edge constraint.

 @param insets The insets for this view's edges from its superview's edges.
 @return An array of constraints added.
 */
- (NSArray *)autoPinEdgesToSuperviewEdgesWithInsets:(ALEdgeInsets)insets
{
    NSMutableArray *constraints = [NSMutableArray new];
    [constraints addObject:[self autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:insets.top]];
    [constraints addObject:[self autoPinEdgeToSuperviewEdge:ALEdgeLeading withInset:insets.left]];
    [constraints addObject:[self autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:insets.bottom]];
    [constraints addObject:[self autoPinEdgeToSuperviewEdge:ALEdgeTrailing withInset:insets.right]];
    return constraints;
}

/**
 Pins 3 of the 4 edges of the view to the edges of its superview with the given edge insets, excluding one edge.
 The insets.left corresponds to a leading edge constraint, and insets.right corresponds to a trailing edge constraint.

 @param insets The insets for this view's edges from its superview's edges. The inset corresponding to the excluded edge
               will be ignored.
 @param edge The edge of this view to exclude in pinning to its superview; this method will not apply any constraint to it.
 @return An array of constraints added.
 */
- (NSArray *)autoPinEdgesToSuperviewEdgesWithInsets:(ALEdgeInsets)insets excludingEdge:(ALEdge)edge
{
    NSMutableArray *constraints = [NSMutableArray new];
    if (edge != ALEdgeTop) {
        [constraints addObject:[self autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:insets.top]];
    }
    if (edge != ALEdgeLeading && edge != ALEdgeLeft) {
        [constraints addObject:[self autoPinEdgeToSuperviewEdge:ALEdgeLeading withInset:insets.left]];
    }
    if (edge != ALEdgeBottom) {
        [constraints addObject:[self autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:insets.bottom]];
    }
    if (edge != ALEdgeTrailing && edge != ALEdgeRight) {
        [constraints addObject:[self autoPinEdgeToSuperviewEdge:ALEdgeTrailing withInset:insets.right]];
    }
    return constraints;
}

#if __PureLayout_MinBaseSDK_iOS8

/**
 Pins the given edge of the view to the corresponding margin of its superview.

 @param edge The edge of this view to pin to the corresponding margin of its superview.
 @return The constraint added.
 */
- (NSLayoutConstraint *)autoPinEdgeToSuperviewMargin:(ALEdge)edge
{
    return [self autoPinEdgeToSuperviewMargin:edge relation:NSLayoutRelationEqual];
}

/**
 Pins the given edge of the view to the corresponding margin of its superview as a maximum or minimum.

 @param edge The edge of this view to pin to the corresponding margin of its superview.
 @param relation Whether the edge should be inset by at least, at most, or exactly the superview's margin.
 @return The constraint added.
 */
- (NSLayoutConstraint *)autoPinEdgeToSuperviewMargin:(ALEdge)edge relation:(NSLayoutRelation)relation
{
    self.translatesAutoresizingMaskIntoConstraints = NO;
    ALView *superview = self.superview;
    NSAssert(superview, @"View's superview must not be nil.\nView: %@", self);
    if (edge == ALEdgeBottom || edge == ALEdgeRight || edge == ALEdgeTrailing) {
        // The bottom, right, and trailing relations are inverted
        if (relation == NSLayoutRelationLessThanOrEqual) {
            relation = NSLayoutRelationGreaterThanOrEqual;
        } else if (relation == NSLayoutRelationGreaterThanOrEqual) {
            relation = NSLayoutRelationLessThanOrEqual;
        }
    }
    ALMargin margin = [NSLayoutConstraint al_marginForEdge:edge];
    return [self autoConstrainAttribute:edge toAttribute:margin ofView:superview withOffset:0.0 relation:relation];
}

/**
 Pins the edges of the view to the margins of its superview.

 @return An array of constraints added.
 */
- (NSArray *)autoPinEdgesToSuperviewMargins
{
    NSMutableArray *constraints = [NSMutableArray new];
    [constraints addObject:[self autoPinEdgeToSuperviewMargin:ALEdgeTop]];
    [constraints addObject:[self autoPinEdgeToSuperviewMargin:ALEdgeLeading]];
    [constraints addObject:[self autoPinEdgeToSuperviewMargin:ALEdgeBottom]];
    [constraints addObject:[self autoPinEdgeToSuperviewMargin:ALEdgeTrailing]];
    return constraints;
}

/**
 Pins 3 of the 4 edges of the view to the margins of its superview, excluding one edge.

 @param edge The edge of this view to exclude in pinning to its superview; this method will not apply any constraint to it.
 @return An array of constraints added.
 */
- (NSArray *)autoPinEdgesToSuperviewMarginsExcludingEdge:(ALEdge)edge
{
    NSMutableArray *constraints = [NSMutableArray new];
    if (edge != ALEdgeTop) {
        [constraints addObject:[self autoPinEdgeToSuperviewMargin:ALEdgeTop]];
    }
    if (edge != ALEdgeLeading && edge != ALEdgeLeft) {
        [constraints addObject:[self autoPinEdgeToSuperviewMargin:ALEdgeLeading]];
    }
    if (edge != ALEdgeBottom) {
        [constraints addObject:[self autoPinEdgeToSuperviewMargin:ALEdgeBottom]];
    }
    if (edge != ALEdgeTrailing && edge != ALEdgeRight) {
        [constraints addObject:[self autoPinEdgeToSuperviewMargin:ALEdgeTrailing]];
    }
    return constraints;
}

#endif /* __PureLayout_MinBaseSDK_iOS8 */

#pragma mark Pin Edges

/**
 Pins an edge of the view to a given edge of another view.

 @param edge The edge of this view to pin.
 @param toEdge The edge of the peer view to pin to.
 @param peerView The peer view to pin to. Must be in the same view hierarchy as this view.
 @return The constraint added.
 */
- (NSLayoutConstraint *)autoPinEdge:(ALEdge)edge toEdge:(ALEdge)toEdge ofView:(ALView *)peerView
{
    return [self autoPinEdge:edge toEdge:toEdge ofView:peerView withOffset:0.0];
}

/**
 Pins an edge of the view to a given edge of another view with an offset.

 @param edge The edge of this view to pin.
 @param toEdge The edge of the peer view to pin to.
 @param peerView The peer view to pin to. Must be in the same view hierarchy as this view.
 @param offset The offset between the edge of this view and the edge of the peer view.
 @return The constraint added.
 */
- (NSLayoutConstraint *)autoPinEdge:(ALEdge)edge toEdge:(ALEdge)toEdge ofView:(ALView *)peerView withOffset:(CGFloat)offset
{
    return [self autoPinEdge:edge toEdge:toEdge ofView:peerView withOffset:offset relation:NSLayoutRelationEqual];
}

/**
 Pins an edge of the view to a given edge of another view with an offset as a maximum or minimum.

 @param edge The edge of this view to pin.
 @param toEdge The edge of the peer view to pin to.
 @param peerView The peer view to pin to. Must be in the same view hierarchy as this view.
 @param offset The offset between the edge of this view and the edge of the peer view.
 @param relation Whether the offset should be at least, at most, or exactly equal to the given value.
 @return The constraint added.
 */
- (NSLayoutConstraint *)autoPinEdge:(ALEdge)edge toEdge:(ALEdge)toEdge ofView:(ALView *)peerView withOffset:(CGFloat)offset relation:(NSLayoutRelation)relation
{
    return [self autoConstrainAttribute:edge toAttribute:toEdge ofView:peerView withOffset:offset relation:relation];
}

#pragma mark Align Axes

/**
 Aligns an axis of the view to the same axis of another view.

 @param axis The axis of this view and the peer view to align.
 @param peerView The peer view to align to. Must be in the same view hierarchy as this view.
 @return The constraint added.
 */
- (NSLayoutConstraint *)autoAlignAxis:(ALAxis)axis toSameAxisOfView:(ALView *)peerView
{
    return [self autoAlignAxis:axis toSameAxisOfView:peerView withOffset:0.0];
}

/**
 Aligns an axis of the view to the same axis of another view with an offset.

 @param axis The axis of this view and the peer view to align.
 @param peerView The peer view to align to. Must be in the same view hierarchy as this view.
 @param offset The offset between the axis of this view and the axis of the peer view.
 @return The constraint added.
 */
- (NSLayoutConstraint *)autoAlignAxis:(ALAxis)axis toSameAxisOfView:(ALView *)peerView withOffset:(CGFloat)offset
{
    return [self autoConstrainAttribute:axis toAttribute:axis ofView:peerView withOffset:offset];
}

#pragma mark Match Dimensions

/**
 Matches a dimension of the view to a given dimension of another view.

 @param dimension The dimension of this view to pin.
 @param toDimension The dimension of the peer view to pin to.
 @param peerView The peer view to match to. Must be in the same view hierarchy as this view.
 @return The constraint added.
 */
- (NSLayoutConstraint *)autoMatchDimension:(ALDimension)dimension toDimension:(ALDimension)toDimension ofView:(ALView *)peerView
{
    return [self autoMatchDimension:dimension toDimension:toDimension ofView:peerView withOffset:0.0];
}

/**
 Matches a dimension of the view to a given dimension of another view with an offset.

 @param dimension The dimension of this view to pin.
 @param toDimension The dimension of the peer view to pin to.
 @param peerView The peer view to match to. Must be in the same view hierarchy as this view.
 @param offset The offset between the dimension of this view and the dimension of the peer view.
 @return The constraint added.
 */
- (NSLayoutConstraint *)autoMatchDimension:(ALDimension)dimension toDimension:(ALDimension)toDimension ofView:(ALView *)peerView withOffset:(CGFloat)offset
{
    return [self autoMatchDimension:dimension toDimension:toDimension ofView:peerView withOffset:offset relation:NSLayoutRelationEqual];
}

/**
 Matches a dimension of the view to a given dimension of another view with an offset as a maximum or minimum.

 @param dimension The dimension of this view to pin.
 @param toDimension The dimension of the peer view to pin to.
 @param peerView The peer view to match to. Must be in the same view hierarchy as this view.
 @param offset The offset between the dimension of this view and the dimension of the peer view.
 @param relation Whether the offset should be at least, at most, or exactly equal to the given value.
 @return The constraint added.
 */
- (NSLayoutConstraint *)autoMatchDimension:(ALDimension)dimension toDimension:(ALDimension)toDimension ofView:(ALView *)peerView withOffset:(CGFloat)offset relation:(NSLayoutRelation)relation
{
    return [self autoConstrainAttribute:dimension toAttribute:toDimension ofView:peerView withOffset:offset relation:relation];
}

/**
 Matches a dimension of the view to a multiple of a given dimension of another view.

 @param dimension The dimension of this view to pin.
 @param toDimension The dimension of the peer view to pin to.
 @param peerView The peer view to match to. Must be in the same view hierarchy as this view.
 @param multiplier The multiple of the peer view's given dimension that this view's given dimension should be.
 @return The constraint added.
 */
- (NSLayoutConstraint *)autoMatchDimension:(ALDimension)dimension toDimension:(ALDimension)toDimension ofView:(ALView *)peerView withMultiplier:(CGFloat)multiplier
{
    return [self autoMatchDimension:dimension toDimension:toDimension ofView:peerView withMultiplier:multiplier relation:NSLayoutRelationEqual];
}

/**
 Matches a dimension of the view to a multiple of a given dimension of another view as a maximum or minimum.

 @param dimension The dimension of this view to pin.
 @param toDimension The dimension of the peer view to pin to.
 @param peerView The peer view to match to. Must be in the same view hierarchy as this view.
 @param multiplier The multiple of the peer view's given dimension that this view's given dimension should be.
 @param relation Whether the multiple should be at least, at most, or exactly equal to the given value.
 @return The constraint added.
 */
- (NSLayoutConstraint *)autoMatchDimension:(ALDimension)dimension toDimension:(ALDimension)toDimension ofView:(ALView *)peerView withMultiplier:(CGFloat)multiplier relation:(NSLayoutRelation)relation
{
    return [self autoConstrainAttribute:dimension toAttribute:toDimension ofView:peerView withMultiplier:multiplier relation:relation];
}

#pragma mark Set Dimensions

/**
 Sets the view to a specific size.

 @param size The size to set this view's dimensions to.
 @return An array of constraints added.
 */
- (NSArray *)autoSetDimensionsToSize:(CGSize)size
{
    NSMutableArray *constraints = [NSMutableArray new];
    [constraints addObject:[self autoSetDimension:ALDimensionWidth toSize:size.width]];
    [constraints addObject:[self autoSetDimension:ALDimensionHeight toSize:size.height]];
    return constraints;
}

/**
 Sets the given dimension of the view to a specific size.

 @param dimension The dimension of this view to set.
 @param size The size to set the given dimension to.
 @return The constraint added.
 */
- (NSLayoutConstraint *)autoSetDimension:(ALDimension)dimension toSize:(CGFloat)size
{
    return [self autoSetDimension:dimension toSize:size relation:NSLayoutRelationEqual];
}

/**
 Sets the given dimension of the view to a specific size as a maximum or minimum.

 @param dimension The dimension of this view to set.
 @param size The size to set the given dimension to.
 @param relation Whether the size should be at least, at most, or exactly equal to the given value.
 @return The constraint added.
 */
- (NSLayoutConstraint *)autoSetDimension:(ALDimension)dimension toSize:(CGFloat)size relation:(NSLayoutRelation)relation
{
    self.translatesAutoresizingMaskIntoConstraints = NO;
    NSLayoutAttribute layoutAttribute = [NSLayoutConstraint al_layoutAttributeForAttribute:dimension];
    NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:self attribute:layoutAttribute relatedBy:relation toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:0.0 constant:size];
    [constraint autoInstall];
    return constraint;
}

#pragma mark Set Content Compression Resistance & Hugging

/**
 Sets the priority of content compression resistance for an axis.
 NOTE: This method must be called from within the block passed into the method +[UIView autoSetPriority:forConstraints:]

 @param axis The axis to set the content compression resistance priority for.
 */
- (void)autoSetContentCompressionResistancePriorityForAxis:(ALAxis)axis
{
    NSAssert(_al_isExecutingConstraintsBlock, @"%@ should only be called from within the block passed into the method +[autoSetPriority:forConstraints:]", NSStringFromSelector(_cmd));
    if (_al_isExecutingConstraintsBlock) {
        self.translatesAutoresizingMaskIntoConstraints = NO;
        ALLayoutConstraintAxis constraintAxis = [NSLayoutConstraint al_constraintAxisForAxis:axis];
#if TARGET_OS_IPHONE
        [self setContentCompressionResistancePriority:_al_globalConstraintPriority forAxis:constraintAxis];
#else
        [self setContentCompressionResistancePriority:_al_globalConstraintPriority forOrientation:constraintAxis];
#endif /* TARGET_OS_IPHONE */
    }
}

/**
 Sets the priority of content hugging for an axis.
 NOTE: This method must be called from within the block passed into the method +[UIView autoSetPriority:forConstraints:]

 @param axis The axis to set the content hugging priority for.
 */
- (void)autoSetContentHuggingPriorityForAxis:(ALAxis)axis
{
    NSAssert(_al_isExecutingConstraintsBlock, @"%@ should only be called from within the block passed into the method +[autoSetPriority:forConstraints:]", NSStringFromSelector(_cmd));
    if (_al_isExecutingConstraintsBlock) {
        self.translatesAutoresizingMaskIntoConstraints = NO;
        ALLayoutConstraintAxis constraintAxis = [NSLayoutConstraint al_constraintAxisForAxis:axis];
#if TARGET_OS_IPHONE
        [self setContentHuggingPriority:_al_globalConstraintPriority forAxis:constraintAxis];
#else
        [self setContentHuggingPriority:_al_globalConstraintPriority forOrientation:constraintAxis];
#endif /* TARGET_OS_IPHONE */
    }
}

#pragma mark Constrain Any Attributes

/**
 Constrains an attribute (any ALEdge, ALAxis, or ALDimension) of the view to a given attribute of another view.
 This method can be used to constrain different types of attributes across two views.

 @param ALAttribute Any ALEdge, ALAxis, or ALDimension of this view to constrain.
 @param toALAttribute Any ALEdge, ALAxis, or ALDimension of the peer view to constrain to.
 @param peerView The peer view to constrain to. Must be in the same view hierarchy as this view.
 @return The constraint added.
 */
- (NSLayoutConstraint *)autoConstrainAttribute:(ALAttribute)attribute toAttribute:(ALAttribute)toAttribute ofView:(ALView *)peerView
{
    return [self autoConstrainAttribute:attribute toAttribute:toAttribute ofView:peerView withOffset:0.0];
}

/**
 Constrains an attribute (any ALEdge, ALAxis, or ALDimension) of the view to a given attribute of another view with an offset.
 This method can be used to constrain different types of attributes across two views.

 @param ALAttribute Any ALEdge, ALAxis, or ALDimension of this view to constrain.
 @param toALAttribute Any ALEdge, ALAxis, or ALDimension of the peer view to constrain to.
 @param peerView The peer view to constrain to. Must be in the same view hierarchy as this view.
 @param offset The offset between the attribute of this view and the attribute of the peer view.
 @return The constraint added.
 */
- (NSLayoutConstraint *)autoConstrainAttribute:(ALAttribute)attribute toAttribute:(ALAttribute)toAttribute ofView:(ALView *)peerView withOffset:(CGFloat)offset
{
    return [self autoConstrainAttribute:attribute toAttribute:toAttribute ofView:peerView withOffset:offset relation:NSLayoutRelationEqual];
}

/**
 Constrains an attribute (any ALEdge, ALAxis, or ALDimension) of the view to a given attribute of another view with an offset as a maximum or minimum.
 This method can be used to constrain different types of attributes across two views.

 @param ALAttribute Any ALEdge, ALAxis, or ALDimension of this view to constrain.
 @param toALAttribute Any ALEdge, ALAxis, or ALDimension of the peer view to constrain to.
 @param peerView The peer view to constrain to. Must be in the same view hierarchy as this view.
 @param offset The offset between the attribute of this view and the attribute of the peer view.
 @param relation Whether the offset should be at least, at most, or exactly equal to the given value.
 @return The constraint added.
 */
- (NSLayoutConstraint *)autoConstrainAttribute:(ALAttribute)attribute toAttribute:(ALAttribute)toAttribute ofView:(ALView *)peerView withOffset:(CGFloat)offset relation:(NSLayoutRelation)relation
{
    self.translatesAutoresizingMaskIntoConstraints = NO;
    NSLayoutAttribute layoutAttribute = [NSLayoutConstraint al_layoutAttributeForAttribute:attribute];
    NSLayoutAttribute toLayoutAttribute = [NSLayoutConstraint al_layoutAttributeForAttribute:toAttribute];
    NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:self attribute:layoutAttribute relatedBy:relation toItem:peerView attribute:toLayoutAttribute multiplier:1.0 constant:offset];
    [constraint autoInstall];
    return constraint;
}

/**
 Constrains an attribute (any ALEdge, ALAxis, or ALDimension) of the view to a given attribute of another view with a multiplier.
 This method can be used to constrain different types of attributes across two views.

 @param ALAttribute Any ALEdge, ALAxis, or ALDimension of this view to constrain.
 @param toALAttribute Any ALEdge, ALAxis, or ALDimension of the peer view to constrain to.
 @param peerView The peer view to constrain to. Must be in the same view hierarchy as this view.
 @param multiplier The multiplier between the attribute of this view and the attribute of the peer view.
 @return The constraint added.
 */
- (NSLayoutConstraint *)autoConstrainAttribute:(ALAttribute)attribute toAttribute:(ALAttribute)toAttribute ofView:(ALView *)peerView withMultiplier:(CGFloat)multiplier
{
    return [self autoConstrainAttribute:attribute toAttribute:toAttribute ofView:peerView withMultiplier:multiplier relation:NSLayoutRelationEqual];
}

/**
 Constrains an attribute (any ALEdge, ALAxis, or ALDimension) of the view to a given attribute of another view with a multiplier as a maximum or minimum.
 This method can be used to constrain different types of attributes across two views.

 @param ALAttribute Any ALEdge, ALAxis, or ALDimension of this view to constrain.
 @param toALAttribute Any ALEdge, ALAxis, or ALDimension of the peer view to constrain to.
 @param peerView The peer view to constrain to. Must be in the same view hierarchy as this view.
 @param multiplier The multiplier between the attribute of this view and the attribute of the peer view.
 @param relation Whether the multiplier should be at least, at most, or exactly equal to the given value.
 @return The constraint added.
 */
- (NSLayoutConstraint *)autoConstrainAttribute:(ALAttribute)attribute toAttribute:(ALAttribute)toAttribute ofView:(ALView *)peerView withMultiplier:(CGFloat)multiplier relation:(NSLayoutRelation)relation
{
    self.translatesAutoresizingMaskIntoConstraints = NO;
    NSLayoutAttribute layoutAttribute = [NSLayoutConstraint al_layoutAttributeForAttribute:attribute];
    NSLayoutAttribute toLayoutAttribute = [NSLayoutConstraint al_layoutAttributeForAttribute:toAttribute];
    NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:self attribute:layoutAttribute relatedBy:relation toItem:peerView attribute:toLayoutAttribute multiplier:multiplier constant:0.0];
    [constraint autoInstall];
    return constraint;
}

#pragma mark Pin to Layout Guides

#if TARGET_OS_IPHONE

/**
 Pins the top edge of the view to the top layout guide of the given view controller with an inset.
 For compatibility with iOS 6 (where layout guides do not exist), this method will simply pin the top edge of
 the view to the top edge of the given view controller's view with an inset.

 @param viewController The view controller whose topLayoutGuide should be used to pin to.
 @param inset The amount to inset this view's top edge from the layout guide.
 @return The constraint added.
 */
- (NSLayoutConstraint *)autoPinToTopLayoutGuideOfViewController:(UIViewController *)viewController withInset:(CGFloat)inset
{
    if (__PureLayout_MinSysVer_iOS7) {
        self.translatesAutoresizingMaskIntoConstraints = NO;
        NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:viewController.topLayoutGuide attribute:NSLayoutAttributeBottom multiplier:1.0 constant:inset];
        [viewController.view al_addConstraintUsingGlobalPriority:constraint]; // Can't use autoInstall because the layout guide is not a view
        return constraint;
    } else {
        // iOS 6 fallback
        return [self autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:viewController.view withOffset:inset];
    }
}

/**
 Pins the bottom edge of the view to the bottom layout guide of the given view controller with an inset.
 For compatibility with iOS 6 (where layout guides do not exist), this method will simply pin the bottom edge of
 the view to the bottom edge of the given view controller's view with an inset.

 @param viewController The view controller whose bottomLayoutGuide should be used to pin to.
 @param inset The amount to inset this view's bottom edge from the layout guide.
 @return The constraint added.
 */
- (NSLayoutConstraint *)autoPinToBottomLayoutGuideOfViewController:(UIViewController *)viewController withInset:(CGFloat)inset
{
    if (__PureLayout_MinSysVer_iOS7) {
        self.translatesAutoresizingMaskIntoConstraints = NO;
        NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:viewController.bottomLayoutGuide attribute:NSLayoutAttributeTop multiplier:1.0 constant:-inset];
        [viewController.view al_addConstraintUsingGlobalPriority:constraint]; // Can't use autoInstall because the layout guide is not a view
        return constraint;
    } else {
        // iOS 6 fallback
        return [self autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:viewController.view withOffset:-inset];
    }
}

#endif /* TARGET_OS_IPHONE */

#pragma mark Internal Methods

/**
 Applies the global constraint priority to the given constraint. This should be done before installing all constraints.

 @param constraint The constraint to set the global priority on and then activate.
 */
+ (void)al_applyGlobalPriorityToConstraint:(NSLayoutConstraint *)constraint
{
    constraint.priority = _al_globalConstraintPriority;
}

/**
 Adds the given constraint to this view after setting the constraint's priority to the global constraint priority.
 NOTE: This method is compatible with all versions of iOS, and should be used for older versions before the active
 property on NSLayoutConstraint was introduced.

 This method should be the only one that calls the UIView/NSView addConstraint: method directly.

 @param constraint The constraint to set the global priority on and then add to this view.
 */
- (void)al_addConstraintUsingGlobalPriority:(NSLayoutConstraint *)constraint
{
    [ALView al_applyGlobalPriorityToConstraint:constraint];
    if (![ALView al_preventAutomaticConstraintInstallation]) {
        [self addConstraint:constraint];
    }
}

/**
 Returns the common superview for this view and the given peer view.
 Raises an exception if this view and the peer view do not share a common superview.

 @return The common superview for the two views.
 */
- (ALView *)al_commonSuperviewWithView:(ALView *)peerView
{
    ALView *commonSuperview = nil;
    ALView *startView = self;
    do {
#if TARGET_OS_IPHONE
        if ([peerView isDescendantOfView:startView]) {
            commonSuperview = startView;
        }
#else
        if ([peerView isDescendantOf:startView]) {
            commonSuperview = startView;
        }
#endif /* TARGET_OS_IPHONE */
        startView = startView.superview;
    } while (startView && !commonSuperview);
    NSAssert(commonSuperview, @"Can't constrain two views that do not share a common superview. Make sure that both views have been added into the same view hierarchy.");
    return commonSuperview;
}

/**
 Aligns this view to a peer view with an alignment option.

 @param peerView The peer view to align to.
 @param alignment The alignment option to apply to the two views.
 @param axis The axis along which the views are distributed, used to validate the alignment option.
 @return The constraint added.
 */
- (NSLayoutConstraint *)al_alignToView:(ALView *)peerView withOption:(NSLayoutFormatOptions)alignment forAxis:(ALAxis)axis
{
    NSLayoutConstraint *constraint = nil;
    switch (alignment) {
        case NSLayoutFormatAlignAllCenterX:
            NSAssert(axis == ALAxisVertical, @"Cannot align views that are distributed horizontally with NSLayoutFormatAlignAllCenterX.");
            constraint = [self autoAlignAxis:ALAxisVertical toSameAxisOfView:peerView];
            break;
        case NSLayoutFormatAlignAllCenterY:
            NSAssert(axis != ALAxisVertical, @"Cannot align views that are distributed vertically with NSLayoutFormatAlignAllCenterY.");
            constraint = [self autoAlignAxis:ALAxisHorizontal toSameAxisOfView:peerView];
            break;
        case NSLayoutFormatAlignAllBaseline: // same value as NSLayoutFormatAlignAllLastBaseline
            NSAssert(axis != ALAxisVertical, @"Cannot align views that are distributed vertically with NSLayoutFormatAlignAllBaseline.");
            constraint = [self autoAlignAxis:ALAxisBaseline toSameAxisOfView:peerView];
            break;
#if __PureLayout_MinBaseSDK_iOS8
        case NSLayoutFormatAlignAllFirstBaseline:
            NSAssert(__PureLayout_MinSysVer_iOS8, @"NSLayoutFormatAlignAllFirstBaseline is only supported on iOS 8.0 or higher.");
            NSAssert(axis != ALAxisVertical, @"Cannot align views that are distributed vertically with NSLayoutFormatAlignAllFirstBaseline.");
            constraint = [self autoAlignAxis:ALAxisFirstBaseline toSameAxisOfView:peerView];
            break;
#endif /* __PureLayout_MinBaseSDK_iOS8 */
        case NSLayoutFormatAlignAllTop:
            NSAssert(axis != ALAxisVertical, @"Cannot align views that are distributed vertically with NSLayoutFormatAlignAllTop.");
            constraint = [self autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:peerView];
            break;
        case NSLayoutFormatAlignAllLeft:
            NSAssert(axis == ALAxisVertical, @"Cannot align views that are distributed horizontally with NSLayoutFormatAlignAllLeft.");
            constraint = [self autoPinEdge:ALEdgeLeft toEdge:ALEdgeLeft ofView:peerView];
            break;
        case NSLayoutFormatAlignAllBottom:
            NSAssert(axis != ALAxisVertical, @"Cannot align views that are distributed vertically with NSLayoutFormatAlignAllBottom.");
            constraint = [self autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:peerView];
            break;
        case NSLayoutFormatAlignAllRight:
            NSAssert(axis == ALAxisVertical, @"Cannot align views that are distributed horizontally with NSLayoutFormatAlignAllRight.");
            constraint = [self autoPinEdge:ALEdgeRight toEdge:ALEdgeRight ofView:peerView];
            break;
        case NSLayoutFormatAlignAllLeading:
            NSAssert(axis == ALAxisVertical, @"Cannot align views that are distributed horizontally with NSLayoutFormatAlignAllLeading.");
            constraint = [self autoPinEdge:ALEdgeLeading toEdge:ALEdgeLeading ofView:peerView];
            break;
        case NSLayoutFormatAlignAllTrailing:
            NSAssert(axis == ALAxisVertical, @"Cannot align views that are distributed horizontally with NSLayoutFormatAlignAllTrailing.");
            constraint = [self autoPinEdge:ALEdgeTrailing toEdge:ALEdgeTrailing ofView:peerView];
            break;
        default:
            NSAssert(nil, @"Unsupported alignment option.");
            break;
    }
    return constraint;
}

@end


text:
<!DOCTYPE html>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>用户管理</title>

    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">

    <link rel="stylesheet" href="../../bootstrap/css/bootstrap.min.css">

    <link rel="stylesheet" href="//cdn.bootcss.com/font-awesome/4.5.0/css/font-awesome.min.css">

    <link rel="stylesheet" href="//cdn.bootcss.com/ionicons/2.0.1/css/ionicons.min.css">

    <link rel="stylesheet" href="../../plugins/datatables/dataTables.bootstrap.css">

    <link rel="stylesheet" href="../../dist/css/AdminLTE.min.css">

    <link rel="stylesheet" href="../../dist/css/skins/_all-skins.min.css">

<?php
include_once('../../front/db.php');

$email = $nickname = '';
if (isset($_COOKIE['email'])) {
    $email = $_COOKIE['email'];
}
if (isset($_COOKIE['nickname'])) {
    $nickname = $_COOKIE['nickname'];
}
?>

            闪腾

            闪腾二手车

                Toggle navigation

                            <?php echo $nickname;?>

                                    <?php echo $nickname;?>
                                    Nov. 2012 注册

                                    收藏

                                    发布

                                    购买

                                    资料

                                    退出

<?php echo $nickname;?>

                     在线

            <form action="#" method="get" class="sidebar-form">

                    <input type="text" name="q" class="form-control" placeholder="搜索...">

                <button type="submit" name="search" id="search-btn" class="btn btn-flat"></button>

            </form>

导航

                        信息概览

                        主页管理
                        3

 滑动板

 栏目修改

                        用户管理
                        2

 用户信息

 管理员信息

                        车辆管理
                        2

 车辆信息

 车辆评估

                用户管理
                用户信息

 首页

后台管理

用户信息

管理员表

                                用户 ID
                                Email
                                昵称
                                手机
                                省份
                                城市

                            <?php
                            $result = $con->query('select * from user where rate = 1;');
                            while ($row = $result->fetch_array()) {
                                echo '
'.$row['id'].'	';
                                echo ''.$row['email'].'	';
                                echo ''.$row['nickname'].'	';
                                echo ''.$row['phone'].'	';
                                echo ''.$row['province'].'	';
                                echo ''.$row['city'].'
';
                            }
                            ?>

                                用户 ID
                                Email
                                昵称
                                手机
                                省份
                                城市

                        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>

 警告!

                        以下操作可能会使用户状态改变.

权限提升

                    <form class="form-horizontal" method="POST" action="improve.php">

                                用户 ID:

                                    <input type="improveid" name="improveid" class="form-control" id="improveid" placeholder="">

                            <button type="submit" class="btn btn-info pull-right">提 升</button>

                    </form>

权限降低

                    <form class="form-horizontal" method="POST" action="reduce.php">

                                用户 ID:

                                    <input type="reduceid" name="reduceid" class="form-control" id="reduceid" placeholder="">

                            <button type="submit" class="btn btn-info pull-right">降 低</button>

                    </form>

            版本 0.0.1

        Copyright © 2015-2016 闪腾二手车. 保留所有权利.

Recent Activity

Langdon's Birthday

Will be 23 on April 24th

Frodo Updated His Profile

New phone +1(800)555-1234

Nora Joined Mailing List

nora@example.com

Cron Job 254 Executed

Execution time 5 seconds

Tasks Progress

                                Custom Template Design
                                70%

                                Update Resume
                                95%

                                Laravel Integration
                                50%

                                Back End Framework
                                68%

Stats Tab Content

                <form method="post">

General Settings

                            Report panel usage
                            <input type="checkbox" class="pull-right" checked>

                            Some information about this general settings option

                            Allow mail redirect
                            <input type="checkbox" class="pull-right" checked>

                            Other sets of options are available

                            Expose author name in posts
                            <input type="checkbox" class="pull-right" checked>

                            Allow the user to show his name in blog posts

Chat Settings

                            Show me as online
                            <input type="checkbox" class="pull-right" checked>

                            Turn off notifications
                            <input type="checkbox" class="pull-right">

                            Delete chat history

                </form>

redpajama_set_name: RedPajamaGithub


text:
	{% if include.post.author_staff_member %}
  Publicado por {{include.post.author_staff_member}}
  {% endif %}

	{% if include.post.date %}
	em {{ include.post.date | date: "%m/%d/%Y" }}
	{% endif %}

{% for category in include.post.categories %}

		{{ category | capitalize }}

{% endfor %}


text:
package org.killbill.billing.plugin.stripe;

import java.util.Properties;

import org.killbill.billing.osgi.libs.killbill.OSGIKillbillAPI;
import org.killbill.billing.plugin.api.notification.PluginTenantConfigurableConfigurationHandler;

public class StripeConfigPropertiesConfigurationHandler extends PluginTenantConfigurableConfigurationHandler<StripeConfigProperties> {

    private final String region;

    public StripeConfigPropertiesConfigurationHandler(final String pluginName,
                                                      final OSGIKillbillAPI osgiKillbillAPI,
                                                      final String region) {
        super(pluginName, osgiKillbillAPI);
        this.region = region;
    }

    @Override
    protected StripeConfigProperties createConfigurable(final Properties properties) {
        return new StripeConfigProperties(properties, region);
    }
}


text:
date: 2016-09-13T09:00:00+00:00
title: Example configurations
menu:
  main:
    identifier: "example-configurations-v095"
    parent: "Configuration"
    weight: 20
---

## reference.conf default settings
reference.conf files are part of the Vamp code and should not be modified. They contains generic defaults for many parameters, but do not constitute a full Vamp configuration. Environment-specific settings need to be added in in application.conf or using environment variables and/or Java system properties.

The Vamp reference.conf file can be found in the Vamp project repo ([github.com/magneticio - Vamp reference.conf](https://github.com/magneticio/vamp/blob/master/bootstrap/src/main/resources/reference.conf)). For links to vendor-specific reference.conf files, see the [Vamp configuration reference](/documentation/configure/v0.9.5/configuration-reference/)

## application.conf
You can use application.conf to tailor the Vamp configuration to fit your environment. Settings specified here, or in environment variables, will override any defaults included in reference.conf. Template configuration files are provided, these complete the standard required settings and include the Vamp Health and Metrics workflows (required by the Vamp UI).  If your environment requires extensive customisation, you can [use a custom application.conf file](/documentation/configure/v0.9.5/configure-vamp/#use-a-custom-application-conf-file).

* [DC/OS application.conf - Vamp v0.9.5](https://github.com/magneticio/vamp-docker-images/blob/0.9.5/vamp-dcos/application.conf)
  _Container driver:_ Marathon
  _Key-value store:_ Zookeeper

* [Kubernetes application.conf - Vamp v0.9.5](https://github.com/magneticio/vamp-docker-images/blob/0.9.5/vamp-kubernetes/application.conf)
  _Container driver:_ Kubernetes
  _Key-value store:_ etcd

{{< note title="What next?" >}}
* Read about [how to configure Vamp](/documentation/configure/v0.9.5/configure-vamp)
* Check the [configuration reference](/documentation/configure/v0.9.5/configuration-reference)
* Follow the [tutorials](/documentation/tutorials/)
* You can read in depth about [using Vamp](/documentation/using-vamp/artifacts/) or browse the [API reference](/documentation/api/api-reference/) or [CLI reference](/documentation/cli/cli-reference/) docs.
{{< /note >}}


text:
shared_examples 'secrets' do |title, params, _facts, defaults|
  ensure_value = params['ensure']
  label        = params['label']
  secret_name  = params['secret_name']
  secret_path  = params['secret_path']

  docker_command = "#{defaults['docker_command']} secret"

  if ensure_value == 'present'
    docker_secrets_flags = get_docker_secrets_flags(
      'ensure' => ensure_value,
      'label'       => label,
      'secret_name' => secret_name,
      'secret_path' => secret_path,
    )

    exec_secret   = [docker_command, docker_secrets_flags]
    unless_secret = [docker_command, 'inspect', secret_name]

    it {
      is_expected.to contain_exec("#{title} docker secret create").with(
        'command' => exec_secret,
        'unless'  => unless_secret,
        'path'    => ['/bin', '/usr/bin'],
      )
    }
  end

  if ensure_value == 'absent'
    it {
      is_expected.to contain_exec("#{title} docker secret rm").with(
        'command' => [docker_command, 'rm', secret_name],
        'onlyif'  => [docker_command, 'inspect', secret_name],
        'path'    => ['/bin', '/usr/bin'],
      )
    }
  end
end


text:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE document PUBLIC "-//Simonsoft//DTD TechDoc Base V1.0 Techdoc//EN" "techdoc.dtd">
<doc name="root" xmlns:cms="http://www.simonsoft.se/namespace/cms"
cms:rid="2gyvymn15kv0000" cms:twords="3">

text

elem <inline>text</inline>

<ph keyref="dita">replaced</ph>

</doc>


text:
package de.slackspace.openkeepass.domain;

import java.util.Calendar;
import java.util.UUID;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

import de.slackspace.openkeepass.xml.BooleanXmlAdapter;
import de.slackspace.openkeepass.xml.UUIDXmlAdapter;

/**
 * Represents the metadata of the KeePass database like database name, custom icons
 * or how much history entries will be preserved.
 *
 */
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Meta {

	@XmlElement(name = "Generator")
	private String generator;

	@XmlElement(name = "DatabaseName")
	private String databaseName;

	@XmlElement(name = "DatabaseDescription")
	private String databaseDescription;

	@XmlElement(name = "DatabaseNameChanged")
	private Calendar databaseNameChanged;

	@XmlElement(name = "DatabaseDescriptionChanged")
	private Calendar databaseDescriptionChanged;

	@XmlElement(name = "MaintenanceHistoryDays")
	private int maintenanceHistoryDays;

	@XmlElement(name = "RecycleBinUUID")
	@XmlJavaTypeAdapter(UUIDXmlAdapter.class)
	private UUID recycleBinUuid;

	@XmlElement(name = "RecycleBinChanged")
	private Calendar recycleBinChanged;

	@XmlElement(name = "RecycleBinEnabled")
	@XmlJavaTypeAdapter(BooleanXmlAdapter.class)
	private Boolean recycleBinEnabled;

	@XmlElement(name = "HistoryMaxItems")
	private long historyMaxItems;

	@XmlElement(name = "HistoryMaxSize")
	private long historyMaxSize;

	@XmlElement(name = "CustomIcons")
	private CustomIcons customIcons;

	Meta() {}

	public Meta(MetaBuilder metaBuilder) {
		this.databaseDescription = metaBuilder.databaseDescription;
		this.databaseDescriptionChanged = metaBuilder.databaseDescriptionChanged;
		this.databaseName = metaBuilder.databaseName;
		this.databaseNameChanged = metaBuilder.databaseNameChanged;
		this.generator = metaBuilder.generator;
		this.historyMaxItems = metaBuilder.historyMaxItems;
		this.historyMaxSize = metaBuilder.historyMaxSize;
		this.maintenanceHistoryDays = metaBuilder.maintenanceHistoryDays;
		this.recycleBinChanged = metaBuilder.recycleBinChanged;
		this.recycleBinEnabled = metaBuilder.recycleBinEnabled;
		this.recycleBinUuid = metaBuilder.recycleBinUuid;
	}

	public String getDatabaseName() {
		return databaseName;
	}

	public String getDatabaseDescription() {
		return databaseDescription;
	}

	public String getGenerator() {
		return generator;
	}

	public Calendar getDatabaseNameChanged() {
		return databaseNameChanged;
	}

	public Calendar getDatabaseDescriptionChanged() {
		return databaseDescriptionChanged;
	}

	public int getMaintenanceHistoryDays() {
		return maintenanceHistoryDays;
	}

	public UUID getRecycleBinUuid() {
		return recycleBinUuid;
	}

	public Calendar getRecycleBinChanged() {
		return recycleBinChanged;
	}

	public long getHistoryMaxItems() {
		return historyMaxItems;
	}

	public long getHistoryMaxSize() {
		return historyMaxSize;
	}

	public boolean getRecycleBinEnabled() {
		return recycleBinEnabled;
	}

	public CustomIcons getCustomIcons() {
		return customIcons;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((customIcons == null) ? 0 : customIcons.hashCode());
		result = prime * result + ((databaseDescription == null) ? 0 : databaseDescription.hashCode());
		result = prime * result + ((databaseDescriptionChanged == null) ? 0 : databaseDescriptionChanged.hashCode());
		result = prime * result + ((databaseName == null) ? 0 : databaseName.hashCode());
		result = prime * result + ((databaseNameChanged == null) ? 0 : databaseNameChanged.hashCode());
		result = prime * result + ((generator == null) ? 0 : generator.hashCode());
		result = prime * result + (int) (historyMaxItems ^ (historyMaxItems >>> 32));
		result = prime * result + (int) (historyMaxSize ^ (historyMaxSize >>> 32));
		result = prime * result + maintenanceHistoryDays;
		result = prime * result + ((recycleBinChanged == null) ? 0 : recycleBinChanged.hashCode());
		result = prime * result + ((recycleBinEnabled == null) ? 0 : recycleBinEnabled.hashCode());
		result = prime * result + ((recycleBinUuid == null) ? 0 : recycleBinUuid.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Meta other = (Meta) obj;
		if (customIcons == null) {
			if (other.customIcons != null)
				return false;
		} else if (!customIcons.equals(other.customIcons))
			return false;
		if (databaseDescription == null) {
			if (other.databaseDescription != null)
				return false;
		} else if (!databaseDescription.equals(other.databaseDescription))
			return false;
		if (databaseDescriptionChanged == null) {
			if (other.databaseDescriptionChanged != null)
				return false;
		} else if (!databaseDescriptionChanged.equals(other.databaseDescriptionChanged))
			return false;
		if (databaseName == null) {
			if (other.databaseName != null)
				return false;
		} else if (!databaseName.equals(other.databaseName))
			return false;
		if (databaseNameChanged == null) {
			if (other.databaseNameChanged != null)
				return false;
		} else if (!databaseNameChanged.equals(other.databaseNameChanged))
			return false;
		if (generator == null) {
			if (other.generator != null)
				return false;
		} else if (!generator.equals(other.generator))
			return false;
		if (historyMaxItems != other.historyMaxItems)
			return false;
		if (historyMaxSize != other.historyMaxSize)
			return false;
		if (maintenanceHistoryDays != other.maintenanceHistoryDays)
			return false;
		if (recycleBinChanged == null) {
			if (other.recycleBinChanged != null)
				return false;
		} else if (!recycleBinChanged.equals(other.recycleBinChanged))
			return false;
		if (recycleBinEnabled == null) {
			if (other.recycleBinEnabled != null)
				return false;
		} else if (!recycleBinEnabled.equals(other.recycleBinEnabled))
			return false;
		if (recycleBinUuid == null) {
			if (other.recycleBinUuid != null)
				return false;
		} else if (!recycleBinUuid.equals(other.recycleBinUuid))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Meta [generator=" + generator + ", databaseName=" + databaseName + ", databaseDescription="
				+ databaseDescription + "]";
	}
}


text:
/*
 * Author: doe300
 *
 * See the file "LICENSE" for the full license governing this code.
 */

#ifndef TEST_EXPRESSIONS_H
#define TEST_EXPRESSIONS_H

#include "cpptest.h"

class TestExpressions : public Test::Suite
{
public:
    TestExpressions();
    ~TestExpressions() override;

    void testCreation();
    void testCombination();
    void testConvergence();
    void testValueRange();
    void testSplit();
    void testAssociativeParts();
};

#endif /* TEST_EXPRESSIONS_H */


text:
const path = require('path');
const TIMRestApi = require('../index.js');

(async () => {

  // get from your app
  // https://console.cloud.tencent.com/avc

  const config = {
    sdkAppid: 'sdkAppid',
    identifier: 'admin identifier',
    accountType: 'admin accountType',
    // version: '201512300000',
    privateKeyPath: path.join(__dirname, './key/private_key'),
    expireAfter: 30 * 24 * 3600
  };

  const api = new TIMRestApi(config);
  api.init();

  // account login info
  console.log(api.loginInfo);

  // test im_open_login_svc/account_import api
  const data = {
    Identifier : 'zack_king',
    Nick : 'Zack King' ,
    FaceUrl : 'https://avatars3.githubusercontent.com/u/8475242?s=460&v=4'
  };
  const serviceName = 'im_open_login_svc';
  const cmdName = 'account_import';

  try {

    const request = await api.request(serviceName, cmdName, data);
    console.log(request.data);

  } catch (error) {

    if (error.response) {

      console.log(error.response.data);
      console.log(error.response.status);
      console.log(error.response.headers);

    } else if (error.request) {

      console.log(error.request);

    } else {

      console.log('Error', error.message);

    }

    console.log(error.config);

  }

})();


text:
import React, { Component } from 'react';
import { List } from 'immutable';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';

import { projectActions } from 'src/projects';

import { I18n } from 'react-i18next';
import { getAuth } from 'src/auth';

import './projects-page.css';

export class ProjectsPage extends Component {
  constructor() {
    super(...arguments);

    this.state = {
      projects: [],
    };
  }

  static propTypes = {
    loadProjects: PropTypes.func.isRequired,
    projects: PropTypes.instanceOf(List).isRequired,
    auth: PropTypes.object.isRequired,
  };

  componentWillMount() {
    this.props.loadProjects();
  }

  componentDidUpdate(prevProps, prevState) {
    if (prevProps.projects === this.props.projects) {
      return;
    }

    const projectsArray = [];

    let counter = 1;
    this.props.projects.forEach(project => {
      projectsArray.push([counter++, project.name, project.url]);
    });

    this.setState({ projects: projectsArray });
  }

  isAdmin() {
    return this.props.auth.role === 'admin';
  }

  render() {
    return (
      <I18n ns="translations">
        {t => (

{t('projects.header')}

                <tr className={`dir-${t('lang-float-reverse')}`}>
                  #
                  {t('projects.name')}

                {this.state.projects.map(project => (
                  <tr
                    key={project[0]}
                    className={`dir-${t('lang-float-reverse')}`}
                  >
                    {project[0]}

                        {project[1]}

                ))}

        )}
      </I18n>
    );
  }
}

//=====================================
//  CONNECT
//-------------------------------------
const mapStateToProps = state => {
  return {
    projects: state.projects.list,
    auth: getAuth(state),
  };
};

const mapDispatchToProps = Object.assign({}, projectActions);

export default connect(mapStateToProps, mapDispatchToProps)(ProjectsPage);


text:
package com.luciofm.extendedprefs.lib;

import java.lang.reflect.Type;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.WeakHashMap;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.text.TextUtils;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;

public class ExtendedPrefs {

	protected Context context;
	protected SharedPreferences mPrefs;
	protected OnExtendedPreferenceChangeListener changeExtListener;

	private static final Object mContent = new Object();
	private final WeakHashMap<OnExtendedPreferenceChangeListener, Object> mListeners = new WeakHashMap<OnExtendedPreferenceChangeListener, Object>();

	public static ExtendedPrefs getExtendedPreferences(Context context, String name) {
		return getExtendedPreferences(context, name, Context.MODE_PRIVATE);
	}

	public static ExtendedPrefs getExtendedPreferences(Context context, String name, int mode) {
		return new ExtendedPrefs(context, name, mode);
	}

	public static ExtendedPrefsEditor edit(Context context, String name) {
		return getExtendedPreferences(context, name).edit();
	}

	private ExtendedPrefs(Context context, String name, int mode) {
		this.context = context;
		mPrefs = context.getSharedPreferences(name, mode);
	}

	public ExtendedPrefsEditor edit() {
		Editor edit = mPrefs.edit();
		return new ExtendedPrefsEditor(context, edit, false);
	}

	public ExtendedPrefsEditor edit(boolean backup) {
		Editor edit = mPrefs.edit();
		return new ExtendedPrefsEditor(context, edit, backup);
	}

	public boolean contains(String key) {
		return mPrefs.contains(key);
	}

	public Map<String, ?> getAll() {
		return mPrefs.getAll();
	}

	public boolean getBoolean(String key, boolean defValue) {
		return mPrefs.getBoolean(key, defValue);
	}

	public float getFloat(String key, float defValue) {
		return mPrefs.getFloat(key, defValue);
	}

	public int getInt(String key, int defValue) {
		return mPrefs.getInt(key, defValue);
	}

	public long getLong(String key, long defValue) {
		return mPrefs.getLong(key, defValue);
	}

	public String getString(String key, String defValue) {
		return mPrefs.getString(key, defValue);
	}

	public Set<String> getStringSet(String key, Set<String> values) {
		return mPrefs.getStringSet(key, values);
	}

	public String[] getStringArray(String key, String[] values) {
		String jsonString = mPrefs.getString(key, null);
		if (TextUtils.isEmpty(jsonString))
			return values;
		Gson gson = new GsonBuilder().create();
		Type type = new TypeToken<String[]>(){}.getType();
		String[] strings = gson.fromJson(jsonString, type);
		if (strings == null)
			return values;
		return strings;
	}

	public List<?> getList(String key, Type type, List<?> values) {
		String jsonString = mPrefs.getString(key, null);
		if (TextUtils.isEmpty(jsonString))
			return values;
		Gson gson = new GsonBuilder().create();
		List<?> ret = gson.fromJson(jsonString, type);
		if (ret != null)
			return ret;
		return values;
	}

	public Object getData(String key, Type type) {
		String jsonString = mPrefs.getString(key, null);
		if (TextUtils.isEmpty(jsonString))
			return null;
		Gson gson = new GsonBuilder().create();
		return gson.fromJson(jsonString, type);
	}

    public Object getData(String key, Class clazz) {
        String jsonString = mPrefs.getString(key, null);
        if (TextUtils.isEmpty(jsonString))
            return null;
        Gson gson = new GsonBuilder().create();
        return gson.fromJson(jsonString, clazz);
    }

	public void registerOnExtendedPreferenceChangeListener(
			OnExtendedPreferenceChangeListener listener) {
		mListeners.put(listener, mContent);
		mPrefs.registerOnSharedPreferenceChangeListener(changedListener);
	}

	public void unregisterOnExtendedPreferenceChangeListener(
			OnExtendedPreferenceChangeListener listener) {
		mListeners.remove(listener);
		mPrefs.unregisterOnSharedPreferenceChangeListener(changedListener);
	}

	public interface OnExtendedPreferenceChangeListener {
		/**
		 * Called when a shared preference is changed, added, or removed. This
		 * may be called even if a preference is set to its existing value.
		 *
		 * <p>
		 * This callback will be run on your main thread.
		 *
		 * @param prefs The {@link SharedPreferences}
		 *                          that received the change.
		 * @param key The key of the preference that was changed,
		 *            added, or removed.
		 */
		void onExtendedPreferenceChanged(ExtendedPrefs prefs,
                                         String key);
	}

	private OnSharedPreferenceChangeListener changedListener = new OnSharedPreferenceChangeListener() {

		@Override
		public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
				String key) {
			Set<OnExtendedPreferenceChangeListener> set = mListeners.keySet();
			for (OnExtendedPreferenceChangeListener listener : set) {
				if (listener != null)
					listener.onExtendedPreferenceChanged(ExtendedPrefs.this, key);
			}
		}
	};
}


text:
module Billing
  # Finds and creates accounts as necessary.
  class AccountManager
    include Singleton

    def account_for(household_id:, community_id:)
      Account.find_or_create_by!(household_id: household_id, community_id: community_id)
    end

    # Ensures account exists for given household in own community.
    # We don't auto-create accounts in other communities in cluster since those
    # are less likely to be needed. They will get created automatically by account_for if they are needed.
    def create_household_successful(household)
      return if household.skip_listener_action == :account_create
      account_for(household_id: household.id, community_id: household.community_id)
    end
  end
end


text:
package com.amazonaws.services.eventbridge.model;

import java.io.Serializable;
import javax.annotation.Generated;
import com.amazonaws.protocol.StructuredPojo;
import com.amazonaws.protocol.ProtocolMarshaller;

/**
 *

 * Contains the parameters needed for you to provide custom input to a target based on one or more pieces of data
 * extracted from the event.
 *

 *
 * @see AWS API
 *      Documentation
 */
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class InputTransformer implements Serializable, Cloneable, StructuredPojo {

    /**
     *

     * Map of JSON paths to be extracted from the event. You can then insert these in the template in
     * InputTemplate to produce the output you want to be sent to the target.
     *

     *

     * InputPathsMap is an array key-value pairs, where each value is a valid JSON path. You can have as
     * many as 100 key-value pairs. You must use JSON dot notation, not bracket notation.
     *

     *

     * The keys cannot start with "Amazon Web Services."
     *

     */
    private java.util.Map<String, String> inputPathsMap;
    /**
     *

     * Input template where you specify placeholders that will be filled with the values of the keys from
     * InputPathsMap to customize the data sent to the target. Enclose each InputPathsMaps
     * value in brackets: <value> The InputTemplate must be valid JSON.
     *

     *

     * If InputTemplate is a JSON object (surrounded by curly braces), the following restrictions apply:
     *

     *

     *

     *

     * The placeholder cannot be used as an object key.
     *

     *

     *

     *

     * The following example shows the syntax for using InputPathsMap and InputTemplate.
     *

     *

     *  "InputTransformer":
     *

     *

     * {
     *

     *

     * "InputPathsMap": {"instance": "$.detail.instance","status": "$.detail.status"},
     *

     *

     * "InputTemplate": "<instance> is in state <status>"
     *

     *

     * }
     *

     *

     * To have the InputTemplate include quote marks within a JSON string, escape each quote marks with a
     * slash, as in the following example:
     *

     *

     *  "InputTransformer":
     *

     *

     * {
     *

     *

     * "InputPathsMap": {"instance": "$.detail.instance","status": "$.detail.status"},
     *

     *

     * "InputTemplate": "<instance> is in state \"<status>\""
     *

     *

     * }
     *

     *

     * The InputTemplate can also be valid JSON with varibles in quotes or out, as in the following
     * example:
     *

     *

     *  "InputTransformer":
     *

     *

     * {
     *

     *

     * "InputPathsMap": {"instance": "$.detail.instance","status": "$.detail.status"},
     *

     *

     * "InputTemplate": '{"myInstance": <instance>,"myStatus": "<instance> is in state \"<status>\""}'
     *

     *

     * }
     *

     */
    private String inputTemplate;

    /**
     *

     * Map of JSON paths to be extracted from the event. You can then insert these in the template in
     * InputTemplate to produce the output you want to be sent to the target.
     *

     *

     * InputPathsMap is an array key-value pairs, where each value is a valid JSON path. You can have as
     * many as 100 key-value pairs. You must use JSON dot notation, not bracket notation.
     *

     *

     * The keys cannot start with "Amazon Web Services."
     *

     *
     * @return Map of JSON paths to be extracted from the event. You can then insert these in the template in
     *         InputTemplate to produce the output you want to be sent to the target.

     *

     *         InputPathsMap is an array key-value pairs, where each value is a valid JSON path. You can
     *         have as many as 100 key-value pairs. You must use JSON dot notation, not bracket notation.
     *

     *

     *         The keys cannot start with "Amazon Web Services."
     */

    public java.util.Map<String, String> getInputPathsMap() {
        return inputPathsMap;
    }

    /**
     *

     * Map of JSON paths to be extracted from the event. You can then insert these in the template in
     * InputTemplate to produce the output you want to be sent to the target.
     *

     *

     * InputPathsMap is an array key-value pairs, where each value is a valid JSON path. You can have as
     * many as 100 key-value pairs. You must use JSON dot notation, not bracket notation.
     *

     *

     * The keys cannot start with "Amazon Web Services."
     *

     *
     * @param inputPathsMap
     *        Map of JSON paths to be extracted from the event. You can then insert these in the template in
     *        InputTemplate to produce the output you want to be sent to the target.

     *

     *        InputPathsMap is an array key-value pairs, where each value is a valid JSON path. You can
     *        have as many as 100 key-value pairs. You must use JSON dot notation, not bracket notation.
     *

     *

     *        The keys cannot start with "Amazon Web Services."
     */

    public void setInputPathsMap(java.util.Map<String, String> inputPathsMap) {
        this.inputPathsMap = inputPathsMap;
    }

    /**
     *

     * Map of JSON paths to be extracted from the event. You can then insert these in the template in
     * InputTemplate to produce the output you want to be sent to the target.
     *

     *

     * InputPathsMap is an array key-value pairs, where each value is a valid JSON path. You can have as
     * many as 100 key-value pairs. You must use JSON dot notation, not bracket notation.
     *

     *

     * The keys cannot start with "Amazon Web Services."
     *

     *
     * @param inputPathsMap
     *        Map of JSON paths to be extracted from the event. You can then insert these in the template in
     *        InputTemplate to produce the output you want to be sent to the target.

     *

     *        InputPathsMap is an array key-value pairs, where each value is a valid JSON path. You can
     *        have as many as 100 key-value pairs. You must use JSON dot notation, not bracket notation.
     *

     *

     *        The keys cannot start with "Amazon Web Services."
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public InputTransformer withInputPathsMap(java.util.Map<String, String> inputPathsMap) {
        setInputPathsMap(inputPathsMap);
        return this;
    }

    /**
     * Add a single InputPathsMap entry
     *
     * @see InputTransformer#withInputPathsMap
     * @returns a reference to this object so that method calls can be chained together.
     */

    public InputTransformer addInputPathsMapEntry(String key, String value) {
        if (null == this.inputPathsMap) {
            this.inputPathsMap = new java.util.HashMap<String, String>();
        }
        if (this.inputPathsMap.containsKey(key))
            throw new IllegalArgumentException("Duplicated keys (" + key.toString() + ") are provided.");
        this.inputPathsMap.put(key, value);
        return this;
    }

    /**
     * Removes all the entries added into InputPathsMap.
     *
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public InputTransformer clearInputPathsMapEntries() {
        this.inputPathsMap = null;
        return this;
    }

    /**
     *

     * Input template where you specify placeholders that will be filled with the values of the keys from
     * InputPathsMap to customize the data sent to the target. Enclose each InputPathsMaps
     * value in brackets: <value> The InputTemplate must be valid JSON.
     *

     *

     * If InputTemplate is a JSON object (surrounded by curly braces), the following restrictions apply:
     *

     *

     *

     *

     * The placeholder cannot be used as an object key.
     *

     *

     *

     *

     * The following example shows the syntax for using InputPathsMap and InputTemplate.
     *

     *

     *  "InputTransformer":
     *

     *

     * {
     *

     *

     * "InputPathsMap": {"instance": "$.detail.instance","status": "$.detail.status"},
     *

     *

     * "InputTemplate": "<instance> is in state <status>"
     *

     *

     * }
     *

     *

     * To have the InputTemplate include quote marks within a JSON string, escape each quote marks with a
     * slash, as in the following example:
     *

     *

     *  "InputTransformer":
     *

     *

     * {
     *

     *

     * "InputPathsMap": {"instance": "$.detail.instance","status": "$.detail.status"},
     *

     *

     * "InputTemplate": "<instance> is in state \"<status>\""
     *

     *

     * }
     *

     *

     * The InputTemplate can also be valid JSON with varibles in quotes or out, as in the following
     * example:
     *

     *

     *  "InputTransformer":
     *

     *

     * {
     *

     *

     * "InputPathsMap": {"instance": "$.detail.instance","status": "$.detail.status"},
     *

     *

     * "InputTemplate": '{"myInstance": <instance>,"myStatus": "<instance> is in state \"<status>\""}'
     *

     *

     * }
     *

     *
     * @param inputTemplate
     *        Input template where you specify placeholders that will be filled with the values of the keys from
     *        InputPathsMap to customize the data sent to the target. Enclose each
     *        InputPathsMaps value in brackets: <value> The InputTemplate must be valid
     *        JSON.

     *

     *        If InputTemplate is a JSON object (surrounded by curly braces), the following restrictions
     *        apply:
     *

     *

     *

     *

     *        The placeholder cannot be used as an object key.
     *

     *

     *

     *

     *        The following example shows the syntax for using InputPathsMap and InputTemplate
     *        .
     *

     *

     *         "InputTransformer":
     *

     *

     *        {
     *

     *

     *        "InputPathsMap": {"instance": "$.detail.instance","status": "$.detail.status"},
     *

     *

     *        "InputTemplate": "<instance> is in state <status>"
     *

     *

     *        }
     *

     *

     *        To have the InputTemplate include quote marks within a JSON string, escape each quote marks
     *        with a slash, as in the following example:
     *

     *

     *         "InputTransformer":
     *

     *

     *        {
     *

     *

     *        "InputPathsMap": {"instance": "$.detail.instance","status": "$.detail.status"},
     *

     *

     *        "InputTemplate": "<instance> is in state \"<status>\""
     *

     *

     *        }
     *

     *

     *        The InputTemplate can also be valid JSON with varibles in quotes or out, as in the following
     *        example:
     *

     *

     *         "InputTransformer":
     *

     *

     *        {
     *

     *

     *        "InputPathsMap": {"instance": "$.detail.instance","status": "$.detail.status"},
     *

     *

     *        "InputTemplate": '{"myInstance": <instance>,"myStatus": "<instance> is in state \"<status>\""}'
     *

     *

     *        }
     */

    public void setInputTemplate(String inputTemplate) {
        this.inputTemplate = inputTemplate;
    }

    /**
     *

     * Input template where you specify placeholders that will be filled with the values of the keys from
     * InputPathsMap to customize the data sent to the target. Enclose each InputPathsMaps
     * value in brackets: <value> The InputTemplate must be valid JSON.
     *

     *

     * If InputTemplate is a JSON object (surrounded by curly braces), the following restrictions apply:
     *

     *

     *

     *

     * The placeholder cannot be used as an object key.
     *

     *

     *

     *

     * The following example shows the syntax for using InputPathsMap and InputTemplate.
     *

     *

     *  "InputTransformer":
     *

     *

     * {
     *

     *

     * "InputPathsMap": {"instance": "$.detail.instance","status": "$.detail.status"},
     *

     *

     * "InputTemplate": "<instance> is in state <status>"
     *

     *

     * }
     *

     *

     * To have the InputTemplate include quote marks within a JSON string, escape each quote marks with a
     * slash, as in the following example:
     *

     *

     *  "InputTransformer":
     *

     *

     * {
     *

     *

     * "InputPathsMap": {"instance": "$.detail.instance","status": "$.detail.status"},
     *

     *

     * "InputTemplate": "<instance> is in state \"<status>\""
     *

     *

     * }
     *

     *

     * The InputTemplate can also be valid JSON with varibles in quotes or out, as in the following
     * example:
     *

     *

     *  "InputTransformer":
     *

     *

     * {
     *

     *

     * "InputPathsMap": {"instance": "$.detail.instance","status": "$.detail.status"},
     *

     *

     * "InputTemplate": '{"myInstance": <instance>,"myStatus": "<instance> is in state \"<status>\""}'
     *

     *

     * }
     *

     *
     * @return Input template where you specify placeholders that will be filled with the values of the keys from
     *         InputPathsMap to customize the data sent to the target. Enclose each
     *         InputPathsMaps value in brackets: <value> The InputTemplate must be valid
     *         JSON.

     *

     *         If InputTemplate is a JSON object (surrounded by curly braces), the following restrictions
     *         apply:
     *

     *

     *

     *

     *         The placeholder cannot be used as an object key.
     *

     *

     *

     *

     *         The following example shows the syntax for using InputPathsMap and
     *         InputTemplate.
     *

     *

     *          "InputTransformer":
     *

     *

     *         {
     *

     *

     *         "InputPathsMap": {"instance": "$.detail.instance","status": "$.detail.status"},
     *

     *

     *         "InputTemplate": "<instance> is in state <status>"
     *

     *

     *         }
     *

     *

     *         To have the InputTemplate include quote marks within a JSON string, escape each quote marks
     *         with a slash, as in the following example:
     *

     *

     *          "InputTransformer":
     *

     *

     *         {
     *

     *

     *         "InputPathsMap": {"instance": "$.detail.instance","status": "$.detail.status"},
     *

     *

     *         "InputTemplate": "<instance> is in state \"<status>\""
     *

     *

     *         }
     *

     *

     *         The InputTemplate can also be valid JSON with varibles in quotes or out, as in the following
     *         example:
     *

     *

     *          "InputTransformer":
     *

     *

     *         {
     *

     *

     *         "InputPathsMap": {"instance": "$.detail.instance","status": "$.detail.status"},
     *

     *

     *         "InputTemplate": '{"myInstance": <instance>,"myStatus": "<instance> is in state \"<status>\""}'
     *

     *

     *         }
     */

    public String getInputTemplate() {
        return this.inputTemplate;
    }

    /**
     *

     * Input template where you specify placeholders that will be filled with the values of the keys from
     * InputPathsMap to customize the data sent to the target. Enclose each InputPathsMaps
     * value in brackets: <value> The InputTemplate must be valid JSON.
     *

     *

     * If InputTemplate is a JSON object (surrounded by curly braces), the following restrictions apply:
     *

     *

     *

     *

     * The placeholder cannot be used as an object key.
     *

     *

     *

     *

     * The following example shows the syntax for using InputPathsMap and InputTemplate.
     *

     *

     *  "InputTransformer":
     *

     *

     * {
     *

     *

     * "InputPathsMap": {"instance": "$.detail.instance","status": "$.detail.status"},
     *

     *

     * "InputTemplate": "<instance> is in state <status>"
     *

     *

     * }
     *

     *

     * To have the InputTemplate include quote marks within a JSON string, escape each quote marks with a
     * slash, as in the following example:
     *

     *

     *  "InputTransformer":
     *

     *

     * {
     *

     *

     * "InputPathsMap": {"instance": "$.detail.instance","status": "$.detail.status"},
     *

     *

     * "InputTemplate": "<instance> is in state \"<status>\""
     *

     *

     * }
     *

     *

     * The InputTemplate can also be valid JSON with varibles in quotes or out, as in the following
     * example:
     *

     *

     *  "InputTransformer":
     *

     *

     * {
     *

     *

     * "InputPathsMap": {"instance": "$.detail.instance","status": "$.detail.status"},
     *

     *

     * "InputTemplate": '{"myInstance": <instance>,"myStatus": "<instance> is in state \"<status>\""}'
     *

     *

     * }
     *

     *
     * @param inputTemplate
     *        Input template where you specify placeholders that will be filled with the values of the keys from
     *        InputPathsMap to customize the data sent to the target. Enclose each
     *        InputPathsMaps value in brackets: <value> The InputTemplate must be valid
     *        JSON.

     *

     *        If InputTemplate is a JSON object (surrounded by curly braces), the following restrictions
     *        apply:
     *

     *

     *

     *

     *        The placeholder cannot be used as an object key.
     *

     *

     *

     *

     *        The following example shows the syntax for using InputPathsMap and InputTemplate
     *        .
     *

     *

     *         "InputTransformer":
     *

     *

     *        {
     *

     *

     *        "InputPathsMap": {"instance": "$.detail.instance","status": "$.detail.status"},
     *

     *

     *        "InputTemplate": "<instance> is in state <status>"
     *

     *

     *        }
     *

     *

     *        To have the InputTemplate include quote marks within a JSON string, escape each quote marks
     *        with a slash, as in the following example:
     *

     *

     *         "InputTransformer":
     *

     *

     *        {
     *

     *

     *        "InputPathsMap": {"instance": "$.detail.instance","status": "$.detail.status"},
     *

     *

     *        "InputTemplate": "<instance> is in state \"<status>\""
     *

     *

     *        }
     *

     *

     *        The InputTemplate can also be valid JSON with varibles in quotes or out, as in the following
     *        example:
     *

     *

     *         "InputTransformer":
     *

     *

     *        {
     *

     *

     *        "InputPathsMap": {"instance": "$.detail.instance","status": "$.detail.status"},
     *

     *

     *        "InputTemplate": '{"myInstance": <instance>,"myStatus": "<instance> is in state \"<status>\""}'
     *

     *

     *        }
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public InputTransformer withInputTemplate(String inputTemplate) {
        setInputTemplate(inputTemplate);
        return this;
    }

    /**
     * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
     * redacted from this string using a placeholder value.
     *
     * @return A string representation of this object.
     *
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("{");
        if (getInputPathsMap() != null)
            sb.append("InputPathsMap: ").append(getInputPathsMap()).append(",");
        if (getInputTemplate() != null)
            sb.append("InputTemplate: ").append(getInputTemplate());
        sb.append("}");
        return sb.toString();
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;

        if (obj instanceof InputTransformer == false)
            return false;
        InputTransformer other = (InputTransformer) obj;
        if (other.getInputPathsMap() == null ^ this.getInputPathsMap() == null)
            return false;
        if (other.getInputPathsMap() != null && other.getInputPathsMap().equals(this.getInputPathsMap()) == false)
            return false;
        if (other.getInputTemplate() == null ^ this.getInputTemplate() == null)
            return false;
        if (other.getInputTemplate() != null && other.getInputTemplate().equals(this.getInputTemplate()) == false)
            return false;
        return true;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int hashCode = 1;

        hashCode = prime * hashCode + ((getInputPathsMap() == null) ? 0 : getInputPathsMap().hashCode());
        hashCode = prime * hashCode + ((getInputTemplate() == null) ? 0 : getInputTemplate().hashCode());
        return hashCode;
    }

    @Override
    public InputTransformer clone() {
        try {
            return (InputTransformer) super.clone();
        } catch (CloneNotSupportedException e) {
            throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone() " + "even though we're Cloneable!", e);
        }
    }

    @com.amazonaws.annotation.SdkInternalApi
    @Override
    public void marshall(ProtocolMarshaller protocolMarshaller) {
        com.amazonaws.services.eventbridge.model.transform.InputTransformerMarshaller.getInstance().marshall(this, protocolMarshaller);
    }
}


text:
using System;
using System.Collections.Generic;
using System.Linq;

using BundleTransformer.Core.Assets;
using BundleTransformer.Core.FileSystem;
using BundleTransformer.Core.Resources;

namespace BundleTransformer.Core.Filters
{
	/// <summary>
	/// Filter that responsible for choosing appropriate version
	/// of CSS file, depending on current mode of
	/// web application (debug mode - debug versions of CSS asset files;
	/// release mode - minified versions)
	/// </summary>
	public sealed class CssFileExtensionsFilter : FileExtensionsFilterBase
	{
		/// <summary>
		/// Extensions of CSS files for debug mode
		/// </summary>
		private static readonly string[] _debugCssExtensions = { ".css", ".min.css" };

		/// <summary>
		/// Extensions of CSS files for release mode
		/// </summary>
		private static readonly string[] _releaseCssExtensions = { ".min.css", ".css" };

		/// <summary>
		/// Constructs a instance of CSS file extensions filter
		/// </summary>
		public CssFileExtensionsFilter()
			: this(BundleTransformerContext.Current.FileSystem.GetVirtualFileSystemWrapper())
		{ }

		/// <summary>
		/// Constructs a instance of CSS file extensions filter
		/// </summary>
		/// <param name="virtualFileSystemWrapper">Virtual file system wrapper</param>
		public CssFileExtensionsFilter(IVirtualFileSystemWrapper virtualFileSystemWrapper)
			: base(virtualFileSystemWrapper)
		{ }

		/// <summary>
		/// Chooses a appropriate versions of CSS files, depending on
		/// current mode of web application
		/// </summary>
		/// <param name="assets">Set of CSS assets</param>
		/// <returns>Set of CSS assets adapted for current mode of web application</returns>
		public override IList<IAsset> Transform(IList<IAsset> assets)
		{
			if (assets == null)
			{
				throw new ArgumentNullException(
					nameof(assets),
					string.Format(Strings.Common_ArgumentIsNull, nameof(assets))
				);
			}

			if (assets.Count == 0)
			{
				return assets;
			}

			foreach (var asset in assets.Where(a => a.AssetTypeCode == Constants.AssetTypeCode.Css
				&& !a.Minified))
			{
				bool isMinified;
				string newAssetVirtualPath = GetAppropriateAssetFilePath(asset.VirtualPath, out isMinified);

				asset.VirtualPath = newAssetVirtualPath;
				asset.Minified = isMinified;
			}

			return assets;
		}

		/// <summary>
		/// Gets a version of CSS file virtual path, most appropriate for
		/// current mode of web application
		/// </summary>
		/// <param name="assetVirtualPath">CSS asset virtual file path</param>
		/// <param name="isMinified">Flag indicating what appropriate
		/// virtual file path version of CSS asset is minified</param>
		/// <returns>Virtual path to CSS file, corresponding current mode
		/// of web application</returns>
		protected override string GetAppropriateAssetFilePath(string assetVirtualPath, out bool isMinified)
		{
			string processedAssetVirtualPath = assetVirtualPath.Trim();
			string appropriateAssetVirtualPath = processedAssetVirtualPath;
			isMinified = false;

			if (appropriateAssetVirtualPath.Length > 0)
			{
				// Fill list of file extensions, sorted in order
				// of relevance to current mode of web application
				string[] appropriateFileExtensions = UsageOfPreMinifiedFilesEnabled ?
					_releaseCssExtensions : _debugCssExtensions;

				appropriateAssetVirtualPath = ProbeAssetFilePath(
					Asset.RemoveAdditionalCssFileExtension(appropriateAssetVirtualPath), appropriateFileExtensions);
				isMinified = Asset.IsCssFileWithMinExtension(appropriateAssetVirtualPath);
			}

			return appropriateAssetVirtualPath;
		}
	}
}