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

package com.azure.resourcemanager.applicationinsights.implementation;

import com.azure.core.annotation.BodyParam;
import com.azure.core.annotation.Delete;
import com.azure.core.annotation.ExpectedResponses;
import com.azure.core.annotation.Get;
import com.azure.core.annotation.HeaderParam;
import com.azure.core.annotation.Headers;
import com.azure.core.annotation.Host;
import com.azure.core.annotation.HostParam;
import com.azure.core.annotation.PathParam;
import com.azure.core.annotation.Put;
import com.azure.core.annotation.QueryParam;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceInterface;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.annotation.UnexpectedResponseExceptionType;
import com.azure.core.http.rest.PagedFlux;
import com.azure.core.http.rest.PagedIterable;
import com.azure.core.http.rest.PagedResponse;
import com.azure.core.http.rest.PagedResponseBase;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.RestProxy;
import com.azure.core.management.exception.ManagementException;
import com.azure.core.util.Context;
import com.azure.core.util.FluxUtil;
import com.azure.resourcemanager.applicationinsights.fluent.AnnotationsClient;
import com.azure.resourcemanager.applicationinsights.fluent.models.AnnotationInner;
import com.azure.resourcemanager.applicationinsights.models.AnnotationErrorException;
import com.azure.resourcemanager.applicationinsights.models.AnnotationsListResult;
import java.util.List;
import reactor.core.publisher.Mono;

/** An instance of this class provides access to all the operations defined in AnnotationsClient. */
public final class AnnotationsClientImpl implements AnnotationsClient {
    /** The proxy service used to perform REST calls. */
    private final AnnotationsService service;

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

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

    /**
     * The interface defining all the services for ApplicationInsightsManagementClientAnnotations to be used by the
     * proxy service to perform REST calls.
     */
    @Host("{$host}")
    @ServiceInterface(name = "ApplicationInsightsM")
    private interface AnnotationsService {
        @Headers({"Content-Type: application/json"})
        @Get(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components"
                + "/{resourceName}/Annotations")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(AnnotationErrorException.class)
        Mono<Response<AnnotationsListResult>> list(
            @HostParam("$host") String endpoint,
            @PathParam("resourceGroupName") String resourceGroupName,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceName") String resourceName,
            @QueryParam("start") String start,
            @QueryParam("end") String end,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Put(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components"
                + "/{resourceName}/Annotations")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(AnnotationErrorException.class)
        Mono<Response<List<AnnotationInner>>> create(
            @HostParam("$host") String endpoint,
            @PathParam("resourceGroupName") String resourceGroupName,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceName") String resourceName,
            @BodyParam("application/json") AnnotationInner annotationProperties,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Accept: application/json;q=0.9", "Content-Type: application/json"})
        @Delete(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components"
                + "/{resourceName}/Annotations/{annotationId}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Void>> delete(
            @HostParam("$host") String endpoint,
            @PathParam("resourceGroupName") String resourceGroupName,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceName") String resourceName,
            @PathParam("annotationId") String annotationId,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Get(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components"
                + "/{resourceName}/Annotations/{annotationId}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(AnnotationErrorException.class)
        Mono<Response<List<AnnotationInner>>> get(
            @HostParam("$host") String endpoint,
            @PathParam("resourceGroupName") String resourceGroupName,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceName") String resourceName,
            @PathParam("annotationId") String annotationId,
            @HeaderParam("Accept") String accept,
            Context context);
    }

    /**
     * Gets the list of annotations for a component for given time range.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param resourceName The name of the Application Insights component resource.
     * @param start The start time to query from for annotations, cannot be older than 90 days from current date.
     * @param end The end time to query for annotations.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws AnnotationErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list of annotations for a component for given time range along with {@link PagedResponse} on
     *     successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<AnnotationInner>> listSinglePageAsync(
        String resourceGroupName, String resourceName, String start, String end) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (start == null) {
            return Mono.error(new IllegalArgumentException("Parameter start is required and cannot be null."));
        }
        if (end == null) {
            return Mono.error(new IllegalArgumentException("Parameter end is required and cannot be null."));
        }
        final String apiVersion = "2015-05-01";
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .list(
                            this.client.getEndpoint(),
                            resourceGroupName,
                            apiVersion,
                            this.client.getSubscriptionId(),
                            resourceName,
                            start,
                            end,
                            accept,
                            context))
            .<PagedResponse<AnnotationInner>>map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), null, null))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Gets the list of annotations for a component for given time range.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param resourceName The name of the Application Insights component resource.
     * @param start The start time to query from for annotations, cannot be older than 90 days from current date.
     * @param end The end time to query for annotations.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws AnnotationErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list of annotations for a component for given time range along with {@link PagedResponse} on
     *     successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<AnnotationInner>> listSinglePageAsync(
        String resourceGroupName, String resourceName, String start, String end, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (start == null) {
            return Mono.error(new IllegalArgumentException("Parameter start is required and cannot be null."));
        }
        if (end == null) {
            return Mono.error(new IllegalArgumentException("Parameter end is required and cannot be null."));
        }
        final String apiVersion = "2015-05-01";
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .list(
                this.client.getEndpoint(),
                resourceGroupName,
                apiVersion,
                this.client.getSubscriptionId(),
                resourceName,
                start,
                end,
                accept,
                context)
            .map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), null, null));
    }

    /**
     * Gets the list of annotations for a component for given time range.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param resourceName The name of the Application Insights component resource.
     * @param start The start time to query from for annotations, cannot be older than 90 days from current date.
     * @param end The end time to query for annotations.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws AnnotationErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list of annotations for a component for given time range as paginated response with {@link
     *     PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<AnnotationInner> listAsync(
        String resourceGroupName, String resourceName, String start, String end) {
        return new PagedFlux<>(() -> listSinglePageAsync(resourceGroupName, resourceName, start, end));
    }

    /**
     * Gets the list of annotations for a component for given time range.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param resourceName The name of the Application Insights component resource.
     * @param start The start time to query from for annotations, cannot be older than 90 days from current date.
     * @param end The end time to query for annotations.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws AnnotationErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list of annotations for a component for given time range as paginated response with {@link
     *     PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<AnnotationInner> listAsync(
        String resourceGroupName, String resourceName, String start, String end, Context context) {
        return new PagedFlux<>(() -> listSinglePageAsync(resourceGroupName, resourceName, start, end, context));
    }

    /**
     * Gets the list of annotations for a component for given time range.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param resourceName The name of the Application Insights component resource.
     * @param start The start time to query from for annotations, cannot be older than 90 days from current date.
     * @param end The end time to query for annotations.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws AnnotationErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list of annotations for a component for given time range as paginated response with {@link
     *     PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<AnnotationInner> list(
        String resourceGroupName, String resourceName, String start, String end) {
        return new PagedIterable<>(listAsync(resourceGroupName, resourceName, start, end));
    }

    /**
     * Gets the list of annotations for a component for given time range.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param resourceName The name of the Application Insights component resource.
     * @param start The start time to query from for annotations, cannot be older than 90 days from current date.
     * @param end The end time to query for annotations.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws AnnotationErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list of annotations for a component for given time range as paginated response with {@link
     *     PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<AnnotationInner> list(
        String resourceGroupName, String resourceName, String start, String end, Context context) {
        return new PagedIterable<>(listAsync(resourceGroupName, resourceName, start, end, context));
    }

    /**
     * Create an Annotation of an Application Insights component.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param resourceName The name of the Application Insights component resource.
     * @param annotationProperties Properties that need to be specified to create an annotation of a Application
     *     Insights component.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws AnnotationErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return array of Annotation along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<List<AnnotationInner>>> createWithResponseAsync(
        String resourceGroupName, String resourceName, AnnotationInner annotationProperties) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (annotationProperties == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter annotationProperties is required and cannot be null."));
        } else {
            annotationProperties.validate();
        }
        final String apiVersion = "2015-05-01";
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .create(
                            this.client.getEndpoint(),
                            resourceGroupName,
                            apiVersion,
                            this.client.getSubscriptionId(),
                            resourceName,
                            annotationProperties,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Create an Annotation of an Application Insights component.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param resourceName The name of the Application Insights component resource.
     * @param annotationProperties Properties that need to be specified to create an annotation of a Application
     *     Insights component.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws AnnotationErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return array of Annotation along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<List<AnnotationInner>>> createWithResponseAsync(
        String resourceGroupName, String resourceName, AnnotationInner annotationProperties, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (annotationProperties == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter annotationProperties is required and cannot be null."));
        } else {
            annotationProperties.validate();
        }
        final String apiVersion = "2015-05-01";
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .create(
                this.client.getEndpoint(),
                resourceGroupName,
                apiVersion,
                this.client.getSubscriptionId(),
                resourceName,
                annotationProperties,
                accept,
                context);
    }

    /**
     * Create an Annotation of an Application Insights component.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param resourceName The name of the Application Insights component resource.
     * @param annotationProperties Properties that need to be specified to create an annotation of a Application
     *     Insights component.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws AnnotationErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return array of Annotation on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<List<AnnotationInner>> createAsync(
        String resourceGroupName, String resourceName, AnnotationInner annotationProperties) {
        return createWithResponseAsync(resourceGroupName, resourceName, annotationProperties)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Create an Annotation of an Application Insights component.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param resourceName The name of the Application Insights component resource.
     * @param annotationProperties Properties that need to be specified to create an annotation of a Application
     *     Insights component.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws AnnotationErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return array of Annotation.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public List<AnnotationInner> create(
        String resourceGroupName, String resourceName, AnnotationInner annotationProperties) {
        return createAsync(resourceGroupName, resourceName, annotationProperties).block();
    }

    /**
     * Create an Annotation of an Application Insights component.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param resourceName The name of the Application Insights component resource.
     * @param annotationProperties Properties that need to be specified to create an annotation of a Application
     *     Insights component.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws AnnotationErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return array of Annotation along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<List<AnnotationInner>> createWithResponse(
        String resourceGroupName, String resourceName, AnnotationInner annotationProperties, Context context) {
        return createWithResponseAsync(resourceGroupName, resourceName, annotationProperties, context).block();
    }

    /**
     * Delete an Annotation of an Application Insights component.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param resourceName The name of the Application Insights component resource.
     * @param annotationId The unique annotation ID. This is unique within a Application Insights component.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Void>> deleteWithResponseAsync(
        String resourceGroupName, String resourceName, String annotationId) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (annotationId == null) {
            return Mono.error(new IllegalArgumentException("Parameter annotationId is required and cannot be null."));
        }
        final String apiVersion = "2015-05-01";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .delete(
                            this.client.getEndpoint(),
                            resourceGroupName,
                            apiVersion,
                            this.client.getSubscriptionId(),
                            resourceName,
                            annotationId,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Delete an Annotation of an Application Insights component.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param resourceName The name of the Application Insights component resource.
     * @param annotationId The unique annotation ID. This is unique within a Application Insights component.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Void>> deleteWithResponseAsync(
        String resourceGroupName, String resourceName, String annotationId, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (annotationId == null) {
            return Mono.error(new IllegalArgumentException("Parameter annotationId is required and cannot be null."));
        }
        final String apiVersion = "2015-05-01";
        context = this.client.mergeContext(context);
        return service
            .delete(
                this.client.getEndpoint(),
                resourceGroupName,
                apiVersion,
                this.client.getSubscriptionId(),
                resourceName,
                annotationId,
                context);
    }

    /**
     * Delete an Annotation of an Application Insights component.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param resourceName The name of the Application Insights component resource.
     * @param annotationId The unique annotation ID. This is unique within a Application Insights component.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return A {@link Mono} that completes when a successful response is received.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Void> deleteAsync(String resourceGroupName, String resourceName, String annotationId) {
        return deleteWithResponseAsync(resourceGroupName, resourceName, annotationId).flatMap(ignored -> Mono.empty());
    }

    /**
     * Delete an Annotation of an Application Insights component.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param resourceName The name of the Application Insights component resource.
     * @param annotationId The unique annotation ID. This is unique within a Application Insights component.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public void delete(String resourceGroupName, String resourceName, String annotationId) {
        deleteAsync(resourceGroupName, resourceName, annotationId).block();
    }

    /**
     * Delete an Annotation of an Application Insights component.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param resourceName The name of the Application Insights component resource.
     * @param annotationId The unique annotation ID. This is unique within a Application Insights component.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<Void> deleteWithResponse(
        String resourceGroupName, String resourceName, String annotationId, Context context) {
        return deleteWithResponseAsync(resourceGroupName, resourceName, annotationId, context).block();
    }

    /**
     * Get the annotation for given id.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param resourceName The name of the Application Insights component resource.
     * @param annotationId The unique annotation ID. This is unique within a Application Insights component.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws AnnotationErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the annotation for given id along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<List<AnnotationInner>>> getWithResponseAsync(
        String resourceGroupName, String resourceName, String annotationId) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (annotationId == null) {
            return Mono.error(new IllegalArgumentException("Parameter annotationId is required and cannot be null."));
        }
        final String apiVersion = "2015-05-01";
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .get(
                            this.client.getEndpoint(),
                            resourceGroupName,
                            apiVersion,
                            this.client.getSubscriptionId(),
                            resourceName,
                            annotationId,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Get the annotation for given id.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param resourceName The name of the Application Insights component resource.
     * @param annotationId The unique annotation ID. This is unique within a Application Insights component.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws AnnotationErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the annotation for given id along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<List<AnnotationInner>>> getWithResponseAsync(
        String resourceGroupName, String resourceName, String annotationId, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (annotationId == null) {
            return Mono.error(new IllegalArgumentException("Parameter annotationId is required and cannot be null."));
        }
        final String apiVersion = "2015-05-01";
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .get(
                this.client.getEndpoint(),
                resourceGroupName,
                apiVersion,
                this.client.getSubscriptionId(),
                resourceName,
                annotationId,
                accept,
                context);
    }

    /**
     * Get the annotation for given id.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param resourceName The name of the Application Insights component resource.
     * @param annotationId The unique annotation ID. This is unique within a Application Insights component.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws AnnotationErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the annotation for given id on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<List<AnnotationInner>> getAsync(String resourceGroupName, String resourceName, String annotationId) {
        return getWithResponseAsync(resourceGroupName, resourceName, annotationId)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Get the annotation for given id.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param resourceName The name of the Application Insights component resource.
     * @param annotationId The unique annotation ID. This is unique within a Application Insights component.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws AnnotationErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the annotation for given id.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public List<AnnotationInner> get(String resourceGroupName, String resourceName, String annotationId) {
        return getAsync(resourceGroupName, resourceName, annotationId).block();
    }

    /**
     * Get the annotation for given id.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param resourceName The name of the Application Insights component resource.
     * @param annotationId The unique annotation ID. This is unique within a Application Insights component.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws AnnotationErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the annotation for given id along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<List<AnnotationInner>> getWithResponse(
        String resourceGroupName, String resourceName, String annotationId, Context context) {
        return getWithResponseAsync(resourceGroupName, resourceName, annotationId, context).block();
    }
}


text:
/**
 * Created by focinfi on 14-7-30.
 */

//get board.x
function getBoardX(){
    var n = board.width * Math.cos(board.angle);
    if(board.fix_point == LEFT)
        return board.x + n;
    else
        return board.x + board.width - n;

}

//get board y
function getBoardY(){
    return board.y - board.weight/2 - board.width * Math.sin(board.angle);
}

function getBallX(){
    return ball.x/CANVAS_HEIGHT * 100 + 2 + "%";
}

function getBoardHeartX(){
    return boardHeartX/CANVAS_HEIGHT * 100 + 2 + "%";
}

//get ball's placement

function getBallPointOfFall(){
    return ball.x + ball.vx * (CANVAS_HEIGHT - ball.y - 14) / ball.vy - board.width/2;
}

function getProbability(probability){
    return Math.random() < probability/100;
}

function getBlockColor(block_type){
    var color;

    switch(block_type){
        case -3:
            color = "red";
            break;
        case -2:
            color = "black";
            break;
        case -1:
            color = "white";
            break;
        default:
            color = BLOCK_COLORS[block_type];
            break;
    }

    return color;
}

function getColorWithAlpha(){

    red_n ++;
    if(red_n >= 255)
        red_n = 0;
    return "rgb("+ red_n +", 0, 0)";
}

function setGameResultData(){
    if(newRecord)
        document.getElementById("win_words").textContent = "New Record";

    document.getElementById("result_time").textContent = "Time: " + parseInt(nowGameTime/100/60) + "'" + parseInt(nowGameTime/100%60) + "''";

    document.getElementById("result_hit").textContent = "Hit: " + hitBlocksNum;

    document.getElementById("new_bug_num").textContent = "Bug: " + bugNum;
}

function changeVelocityAfterHit(type){
    switch(type){
        case VY:
            ball.vy *= -1;
            break
        case VX:
            ball.vx *= -1;
            break;
        case VX_Y:
            ball.vx *= -1;
            ball.vy *= -1;
            break;
        case I:
            if(ball.speed_up){
                ball.vx = 20 * BALL_SPEED_UP_TIMES;
                ball.vy = -20 * BALL_SPEED_UP_TIMES;
            }else{
                ball.vx = 20;
                ball.vy = -20;
            }

            break;
        case II:
            if(ball.speed_up){
                ball.vx = -20 * BALL_SPEED_UP_TIMES;
                ball.vy = -20 * BALL_SPEED_UP_TIMES;
            }else{
                ball.vx = -20;
                ball.vy = -20;
            }
            break;
        case III:
            if(ball.speed_up){
                ball.vx = -20 * BALL_SPEED_UP_TIMES;
                ball.vy = 20 * BALL_SPEED_UP_TIMES;
            }else{
                ball.vx = -20;
                ball.vy = 20;
            }
            break;
        case V:

            if(ball.speed_up){
                ball.vx = -20 * BALL_SPEED_UP_TIMES;
                ball.vy = -20 * BALL_SPEED_UP_TIMES;
            }else{
                ball.vx = -20;
                ball.vy = -20;
            }
            break;
        default : break;

    }
}

function afterHitBlocks(i, j){

    hitBlockMusic.play();

    if(blocks.shape[i][j] > 0){
        hitBlocksNum++;
    }

    if(blocks.shape[i][j] == 3){
        if(!ball.speed_up){
            ball.speed_up = true;
            ball.vx *= BALL_SPEED_UP_TIMES;
            ball.vy *= BALL_SPEED_UP_TIMES;
        }
        countSpeedUp += 200;
    }

    if(blocks.shape[i][j] > 0)
        blocks.shape[i][j]--;

    if(blocks.type == BOSS && blocks.shape[i][j] == -3){
        if(gameState == GAME_BEGINNING){
            gameBeginningRestart("GAME WIN!");
        }else{
            gameWin();
        }
    }
}

function adjustBallPosition(direction){
    switch(direction){
        case I:
            ball.x += blocks.vx;
            break;
        case II:
            ball.x -= -1 * blocks.vx;
            break;
        case III:
            ball.x -= -1 * blocks.vx;
            break;
        case V:
            ball.x += blocks.vx;
            break;
    }
}

function developMode(type){
    switch (type){
        case DEBUG:
            Element.setElementStyle(gameDebugShower, "display", "block");
            Element.setElementStyle(document.getElementById("game_title"), "display", "none");
            Element.setElementStyle(contentLeftBoard, "left", "-35.5%");
            Element.setElementStyle(contentRightBoard, "left", "100%");
            developMode = DEBUG;
            break;
        case PLAY:
            developMode = PLAY;
            Element.setElementStyle(gameDebugShower, "display", "none");
            Element.setElementStyle(document.getElementById("game_title"), "display", "block");
        default :break;

    }
}

//game init
function initGame(){

    //bg music
    gameBackgroundMusic.play();

    //scoreboard
    scoreDBFunctions.query();
    bugDBFunctions.query();

    if(bestGameTime == null)
        gameBestTimeBoard.textContent = "Time: Null"
    else
        gameBestTimeBoard.textContent ="Time: " + parseInt(bestGameTime/100/60) + "'" + parseInt(bestGameTime/100%60) + "''";

    gameBestHitNumBoard.textContent = "Hit: " + parseInt(bestHitBlocksNum);
    bugBoard.textContent = "Bug: " + parseInt(bugNum);
    nowTimeBoard.textContent = "Time: 0'0''";
    nowHitBlocksBoard.textContent = "Hit: 0";

    //game state
    gameTime = 0;

    //board
    board.width = BOARD_WIDTH;
    double_board_length = false;
    doubleBoardLengthAvailable = true;
    countDoubleBoardLength = 0;
    hitBlocksNum = 0;

    //ball
    ball.x = BALL_X - Math.random() * 200;
    ball.y = BALL_Y;
    ball.vx = BALL_VX + Math.random() * 5;
    ball.vy = BALL_VY - Math.random() * 5;
    ball.speed_up = false;

    //blocks and boss
    blocks.margin_left = BLOCK_MARGIN_LEFT;
    countCannonTime = 0;
    blocks.shape = deepCopyArray(SHAPES[2]);
    bossCannonsArray = deepCopyArray(BOSSES_CANNONS_ARRAYS[0]);
    bossOffset = 2;
    bossLeftOffsetDirection = RIGHT;
    bombs = [];

    //score shower
    scoreShowerLeft = 0,
    scoreShowerSkew = 20;

}

function initLasers(){
    if(lasers.length < bossCannonsArray.length){

        for(var w = 0; w < bossCannonsArray.length * 2; w ++){

            if(w % 2 == 0){
                var laser_right = {
                    x : 0,
                    length : 0,
                    color : "red",
                    offset : BLOCk_WIDTH/8 * w,
                    vx : 1,
                    vy : 1,
                    a : 1,
                    direction : RIGHT,
                    shot_time : 0}

                lasers.push(laser_right);
            }else{
                var laser_left = {
                    x : 0,
                    length : 0,
                    offset : -1 * BLOCk_WIDTH/8 * (w - 1),
                    vx : -1,
                    vy : 1,
                    a : 1,
                    direction : LEFT,
                    shot_time : 0}

                lasers.push(laser_left);
            }
        }
    }
}

function initLighting(){
    lightingArray = [];
    if(lightingArray.length < 10)
        for(var i = 0; i < 10; i++){
            var lighting = {
                x: BLOCk_WIDTH/10 * i + BLOCk_WIDTH/20 + cannon.x,
                y: cannon.y,
                node_array : new Array()
            }
            var lighting_length_now = 0;
            var lighting_node_left = true;

            for(var j = 1; lighting_length_now <= countCannonTime % 1000 - 500 + BLOCk_WIDTH/4 - Math.abs(i - 4.5) - 2; j++){
                lighting.node_array[j] = new Array();

                if(lighting_node_left){
                    var random_x = lighting.x - Math.random() * BLOCk_WIDTH/10;
                    lighting_node_left = false;
                }else{
                    var random_x = lighting.x + Math.random() * BLOCk_WIDTH/10;
                    lighting_node_left = true;
                }

                var random_y = Math.random() * 1 + 2;
                lighting.node_array[j][0] = parseInt(random_x);
                lighting.node_array[j][1] = parseInt(random_y + lighting_length_now + cannon.y);

                lighting_length_now += random_y;
            }

            lightingArray.push(lighting);
        }
}

function addBombs(){
    if(countCannonTime%100 == 99){
        var bomb = {
            x: cannon.x,
            y: cannon.y + BLOCk_WIDTH,
            vy: 1
        }
//    gameDebugShower.textContent = bombs.length + "_" + bomb.x;

        bombs.push(bomb);
    }
}

function initWater(){
    for(var i = 0; i < 50; i++){
        var water = {
            x_bottom: CANVAS_HEIGHT/50 * i + CANVAS_HEIGHT/100,
            y_bottom: CANVAS_HEIGHT,
            x_top: CANVAS_HEIGHT/50 * i + CANVAS_HEIGHT/100,
            y_top: CANVAS_HEIGHT - (10 - Math.abs(4.5 - i%10)),
            v: 0.1,
            color: colors[6]
        }

        waters.push(water);
    }
}

function initBossBody(){
    var boss_shape = deepCopyArray(blocks.shape);

    if(bossBodyArray.length < 1){
        for(var j = 1; j < boss_shape[0].length - 1; j++){
            var boss_body = {
                x: 0,
                y: 0,
                to_top:BLOCK_MARGIN,
                to_left: blocks.margin_left + j * (BLOCk_WIDTH + BLOCK_MARGIN + 0.5),
                form_top: CANVAS_PADDING,
                form_left: blocks.margin_left + j * (BLOCk_WIDTH + BLOCK_MARGIN + 0.5) - 60,
                vx: 0.001,
                vy: 1,
                a: 1.1,
                level: Math.abs(5 - j),
                direction: LEFT,
                blocks : new Array()
            };

            if(j == 5 ){
                boss_body.form_left = boss_body.to_left = blocks.margin_left + (BLOCk_WIDTH + BLOCK_MARGIN) * 5 + 2.5;
                boss_body.vx = 0;
            }else if(j > 5){
                boss_body.direction = RIGHT;
                boss_body.form_left += 120;
                boss_body.vx *= -1;
            }

            for(var i = 0; i < boss_shape.length - 3; i++){
                boss_body.blocks[i] = new Array();
                if(boss_shape[i][j] == -2)
                    boss_body.blocks[i][0] = boss_shape[i][j] + 1;
                else
                    boss_body.blocks[i][0] = boss_shape[i][j];
            }

            bossBodyArray.push(boss_body);

            //get black array
            if(Math.abs(j - 5) == 3){
                var vertical_black = {
                    x: 0,
                    y: 0,
                    to_top: CANVAS_PADDING,
                    to_left: blocks.margin_left + j * (BLOCk_WIDTH + BLOCK_MARGIN + 0.5),
                    form_top: CANVAS_PADDING - 60,
                    form_left: blocks.margin_left + j * (BLOCk_WIDTH + BLOCK_MARGIN + 0.5),
                    vx: 0.001,
                    vy: 0.001,
                    a: 1.1,
                    level: 5,
                    direction: TOP,
                    blocks : new Array()
                };

                for(var i = 0; i < boss_shape.length - 3; i++){
                    vertical_black.blocks[i] = new Array();
                    if(boss_shape[i][j] == 1)
                        vertical_black.blocks[i][0] = boss_shape[i][j] - 2;
                    else
                        vertical_black.blocks[i][0] = boss_shape[i][j];
                }

                bossBodyArray.push(vertical_black);
            }
        }

        //get horizontal black blocks
        var horizontal_black = {
            x: 0,
            y: 0,
            to_top:CANVAS_PADDING + (BLOCk_WIDTH + BLOCK_MARGIN) * 3,
            to_left: blocks.margin_left + 4 * (BLOCk_WIDTH + BLOCK_MARGIN + 0.5),
            form_top: CANVAS_PADDING + (BLOCk_WIDTH + BLOCK_MARGIN) * 3 + 60,
            form_left: blocks.margin_left + 4 * (BLOCk_WIDTH + BLOCK_MARGIN + 0.5),
            vx: 0.001,
            vy: -0.001,
            a: 1.1,
            level: 5,
            direction: BOTTOM,
            blocks : [[-2, -2, -2]]
        };

        bossBodyArray.push(horizontal_black);
        console.log(horizontal_black);

//        //get boss_leg
        var boss_leg_left = {
            x: 0,
            y: 0,
            to_top:CANVAS_PADDING + (BLOCk_WIDTH + BLOCK_MARGIN) * 5,
            to_left: blocks.margin_left,
            form_top: CANVAS_PADDING + (BLOCk_WIDTH + BLOCK_MARGIN + 0.5) * 5 + 100,
            form_left: blocks.margin_left + (BLOCk_WIDTH + BLOCK_MARGIN),
            vx: 0.001,
            vy: -0.0000001,
            a: 1.2,
            level: 6,
            direction: BOTTOM,
            blocks : [
                [-1, -2, -1],
                [ 1,  3,  1],
                [-2, -1, -2]
            ]
        }

        bossBodyArray.push(boss_leg_left);

        var boss_leg_right = {
            x: 0,
            y: 0,
            form_top: CANVAS_PADDING + (BLOCk_WIDTH + BLOCK_MARGIN + 0.5) * 5 + 100,
            form_left: blocks.margin_left + 7 * (BLOCk_WIDTH + BLOCK_MARGIN + 0.5),
            to_top:CANVAS_PADDING + (BLOCk_WIDTH + BLOCK_MARGIN) * 5,
            to_left: blocks.margin_left + 8 * (BLOCk_WIDTH + BLOCK_MARGIN + 0.5),
            vx: 0.001,
            vy: -0.0000001,
            a: 1.2,
            level: 7,
            direction: BOTTOM,
            blocks : [
                [-1, -2, -1],
                [ 1,  3,  1],
                [-2, -1, -2]
            ]
        }

        bossBodyArray.push(boss_leg_right);
    }
}

function initBossPieces(){

    if(bossPieces.length < 1)
        for(var i = 0; i < blocks.shape.length; i++)
            for(var j = 0; j < blocks.shape[i].length; j++){
                var boss_piece = {
                    x: blocks.margin_left + (BLOCk_WIDTH + BLOCK_MARGIN) * j,
                    y: blocks.margin_top + (BLOCk_WIDTH + BLOCK_MARGIN) * i,
                    vx: 0.1 + Math.random(),
                    vy: -5 - Math.random()*5,
                    a: 1 + Math.random() * 1.5,
                    color_number: blocks.shape[i][j]
                }

                if(getProbability(50))
                    boss_piece.vx *= -1;

                bossPieces.push(boss_piece);

            }
    console.log(bossPieces.length);

}

//UI support
Element.setElementStyle = function(element, key, value){
    element.setAttribute("style", key + ":" + value);
}

Element.showWithScale = function(element, left, words){
    element.textContent = words;
    var scale_time = 0;
    var scale_interval = setInterval(
        function(){
            if(scale_time >= 100){
                clearInterval(scale_interval);
                gameButtonLock = true;

            }
//            gameDebugShower.textContent = left;
            var style = "left:" + left + ";";
            Element.setElementStyle(element, style + "transform", "scale("+ (scale_time/100).toString() +")");
            scale_time++;

        }
    );
}

Element.hideWithAnimation = function(element, left){

//    var le = element.getAttribute("style");
//    alert(le)
    var scale_time = 100;
    var scale_interval = setInterval(
        function(){
            if(scale_time <= 0){
                clearInterval(scale_interval);
            }
            var style = "left:" + left + ";";
            Element.setElementStyle(element, style + "transform", "scale("+ (scale_time/100).toString() +")");
            scale_time--;

        }
    );
}

Element.show = function(element, words){
    element.textContent = words;
    Element.setElementStyle(element, "visibility", "visible");
}

Element.hide = function(element){
    Element.setElementStyle(element, "visibility", "hidden");
}

function setCss(element, key, value){
    Element.setElementStyle(element, key, value);
}

function showMessageSoon(left, words){
//    Element.setElementStyle(gameMessageShower, "left", (getBallX()).toString()+"%");
//    setCss(gameMessageShower, "left", "10%");
    Element.showWithScale(gameMessageShower, left, words);

    setTimeout(function(){
            Element.hideWithAnimation(gameMessageShower, left);
            game_message_shower_lock = false
        },
        2000
    );
}

function showBossDialogSoon(left, words){
//    Element.setElementStyle(gameMessageShower, "left", (getBallX()).toString()+"%");
//    setCss(gameMessageShower, "left", "10%");
    Element.showWithScale(gameBossDialog, left, words);

    setTimeout(function(){
            Element.hideWithAnimation(gameBossDialog, left);
            game_message_shower_lock = false
        },
        2000
    );
}

function showMessageForever(words){
    Element.showWithScale(gameMessageShower, getBoardHeartX(), words);
}

function hideMessage(){
    Element.hideWithAnimation(gameMessageShower, getBoardHeartX());

}

function showCountdownBoard(words){
//    Element.show(game_countdown_board, words);

    game_countdown_board.textContent = words;
    var scale_time = 50;
    var scale_interval = setInterval(
        function(){
            if(scale_time >= 150){
                clearInterval(scale_interval);
                hideCountdownBoard();
            }

            Element.setElementStyle(game_countdown_board, "transform", "scale("+ (scale_time/100).toString() +")");
            scale_time++;

        }
    );
}

function hideCountdownBoard(){
    Element.hide(game_countdown_board);
}

function showGameButton(words){
    Element.showWithScale(gameStateButton, "40%", words);
}

function hideGameButton(){
    Element.hideWithAnimation(gameStateButton, "40%");
}

function showGameResultBoard(){
    Element.show(gameResultBoard,"");
}

function hideGameResultBoard(){
    Element.hideWithAnimation(gameResultBoard, "30%");
}

function gameBeginningRestart(words){
    showMessageSoon(getBallX(), words);

    clearInterval(gameBeginningInterval);
    setTimeout(
        function(){
            gameBeginning();
        },
        2500);

}

redpajama_set_name: RedPajamaGithub


text:
/* @file
 * Interface to connect a simulated ethernet device to the real world
 */

#ifndef __ETHERTAP_HH__
#define __ETHERTAP_HH__

#include <queue>
#include <string>

#include "base/pollevent.hh"
#include "dev/etherobject.hh"
#include "dev/etherint.hh"
#include "dev/etherpkt.hh"
#include "params/EtherTap.hh"
#include "sim/eventq.hh"
#include "sim/sim_object.hh"

class TapEvent;
class TapListener;
class EtherTapInt;

/*
 * Interface to connect a simulated ethernet device to the real world
 */
class EtherTap : public EtherObject
{
  protected:
    friend class TapEvent;
    TapEvent *event;

  protected:
    friend class TapListener;
    TapListener *listener;
    int socket;
    char *buffer;
    int buflen;
    uint32_t buffer_offset;
    uint32_t data_len;

    EtherDump *dump;

    void attach(int fd);
    void detach();

  protected:
    std::string device;
    std::queue<EthPacketPtr> packetBuffer;
    EtherTapInt *interface;

    void process(int revent);
    void enqueue(EthPacketData *packet);
    void retransmit();

    /*
     */
    class TxEvent : public Event
    {
      protected:
        EtherTap *tap;

      public:
        TxEvent(EtherTap *_tap) : tap(_tap) {}
        void process() { tap->retransmit(); }
        virtual const char *description() const
            { return "EtherTap retransmit"; }
    };

    friend class TxEvent;
    TxEvent txEvent;

  public:
    typedef EtherTapParams Params;
    EtherTap(const Params *p);
    virtual ~EtherTap();

    const Params *
    params() const
    {
        return dynamic_cast<const Params *>(_params);
    }

    virtual EtherInt *getEthPort(const std::string &if_name, int idx);

    virtual bool recvPacket(EthPacketPtr packet);
    virtual void sendDone();

    virtual void serialize(std::ostream &os);
    virtual void unserialize(Checkpoint *cp, const std::string &section);
};

class EtherTapInt : public EtherInt
{
  private:
    EtherTap *tap;
  public:
    EtherTapInt(const std::string &name, EtherTap *t)
            : EtherInt(name), tap(t)
    { }

    virtual bool recvPacket(EthPacketPtr pkt) { return tap->recvPacket(pkt); }
    virtual void sendDone() { tap->sendDone(); }
};

#endif // __ETHERTAP_HH__


text:
package org.dvare.test.utility;

import org.dvare.binding.rule.RuleBinding;
import org.dvare.config.RuleConfiguration;
import org.dvare.evaluator.RuleEvaluator;
import org.dvare.exceptions.interpreter.InterpretException;
import org.dvare.exceptions.parser.ExpressionParseException;
import org.dvare.expression.Expression;
import org.dvare.parser.ExpressionTokenizer;
import org.dvare.test.dataobjects.Parenthesis;
import org.junit.jupiter.api.Test;

import java.util.Arrays;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class ParenthesisTest {
    @Test
    public void testApp() throws ExpressionParseException, InterpretException {

        RuleConfiguration factory = new RuleConfiguration();

        String expr = "Variable1 = 'A'" +
                " AND ( ( Variable2 = 'O'" +
                " AND Variable3 = 'R' )" +
                " OR ( Variable4 = 'G'" +
                " AND Variable5 = 'M' ) )";
        Expression expression = factory.getParser().fromString(expr, Parenthesis.class);

        RuleBinding rule = new RuleBinding(expression);

        Parenthesis parenthesis = new Parenthesis();
        parenthesis.setVariable1("A");
        parenthesis.setVariable2("O");
        parenthesis.setVariable3("R");
        parenthesis.setVariable4("K");
        parenthesis.setVariable5("M");

        RuleEvaluator evaluator = factory.getEvaluator();
        boolean result = (Boolean) evaluator.evaluate(rule, parenthesis);
        assertTrue(result);
    }

    @Test
    public void testApp1() throws ExpressionParseException, InterpretException {

        String expr = "Variable1 = ('dvare(framework)')";

        String[] tokens = ExpressionTokenizer.toToken(expr);

        assertEquals(tokens.length, 5);

    }

    @Test
    public void testApp2() throws ExpressionParseException {

        String expr = "Variable1 = ('dvare(framework)' )";

        String[] tokens = ExpressionTokenizer.toToken(expr);

        assertEquals(tokens.length, 5);

    }

    @Test
    public void testApp3() throws ExpressionParseException {

        String expr = "Variable1 = ( 'dvare(framework)')";

        String[] tokens = ExpressionTokenizer.toToken(expr);

        assertEquals(tokens.length, 5);

    }

    @Test
    public void testApp4() throws ExpressionParseException {

        String expr = "Variable1 = ('dvare (framework)')";
        String[] tokens = ExpressionTokenizer.toToken(expr);

        assertEquals(tokens.length, 5);
        assertEquals(Arrays.asList(tokens), Arrays.asList("Variable1", "=", "(", "'dvare (framework)'", ")"));

    }

    @Test
    public void testApp5() throws ExpressionParseException, InterpretException {

        RuleConfiguration factory = new RuleConfiguration();

        String expr = "Variable1 = 'dvare(framework)' and Variable2 = 'dvare framework'";

        Expression expression = factory.getParser().fromString(expr, Parenthesis.class);

        RuleBinding rule = new RuleBinding(expression);

        Parenthesis parenthesis = new Parenthesis();
        parenthesis.setVariable1("dvare(framework)");
        parenthesis.setVariable2("dvare framework");

        RuleEvaluator evaluator = factory.getEvaluator();
        boolean result = (Boolean) evaluator.evaluate(rule, parenthesis);
        assertTrue(result);
    }

}


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

/**
 *
 */
public enum TlsPolicy {

    Require("Require"),
    Optional("Optional");

    private String value;

    private TlsPolicy(String value) {
        this.value = value;
    }

    @Override
    public String toString() {
        return this.value;
    }

    /**
     * Use this in place of valueOf.
     *
     * @param value
     *        real value
     * @return TlsPolicy corresponding to the value
     */
    public static TlsPolicy fromValue(String value) {
        if (value == null || "".equals(value)) {
            throw new IllegalArgumentException("Value cannot be null or empty!");
        }

        for (TlsPolicy enumEntry : TlsPolicy.values()) {
            if (enumEntry.toString().equals(value)) {
                return enumEntry;
            }
        }

        throw new IllegalArgumentException("Cannot create enum from " + value
                + " value!");
    }
}


text:
This plugin has still some serious flaws! A list can be found on the bottom of this readme.

Gist plugin for Redactor WYSIWYG-Editor
===

This is a Redactor plugin which introduces a new button in the interface for adding Github Gists.
![Gist Plugin Screenshot](http://i.imgur.com/4JGsd.png)

Activate Plugin
---
Simply follow the instructions on the [official documentation](http://imperavi.com/redactor/docs/creatingplugins/) or take a look at the following minimal example.

```html
<!DOCTYPE html>
<html>
<head>
    <title>Redactor Gist plugin is awesome!</title>
    <meta charset="utf-8">

    <link rel="stylesheet" href="http://imperavi.com/js/redactor/redactor.css" />
    <link rel="stylesheet" href="https://raw.github.com/1up-lab/redactorjs-gist-plugin/master/gist.css" />

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
    <script src="http://imperavi.com/js/redactor/redactor.js"></script>
    <script src="https://raw.github.com/1up-lab/redactorjs-gist-plugin/master/gist.js"></script>

    <script type="text/javascript">
    $(document).ready(function()
    {
        $('#redactor').redactor(
        {
            plugins: ['gist']
        });
    });
    </script>
</head>
<body>
    <div id="page">
        <textarea id="redactor" name="content"></textarea>
    </div>
</body>
</html>
```

That's all! No additional assets like images needed. They are integrated inline in the CSS file.

Known Flaws
---
* This plugin does not work on the current community-version of RedactorJS as it does not support plugins.
* There is still a bug when loading the editor with gist script-tags in the content, as they will be stripped. Hey RedactorJS-devs: post-submit hooks would be nice. Consider that.
* When pasting a Gist-URL to the editor and forget to unlink the element, the gist itself will be clickable, because the surrounding link is not removed. If you have an idea how to work around this flaw, drop me line!
* Templating could be nicer. Working with DOM-Elements instead of string-values for example.

Thanks!
---
You're welcome.

---
[Jim Schmid](https://github.com/sheeep) for [1up.io](http://1up.io)


text:
package com.googlecode.objectify.condition;

/**
 *
Simple If condition that returns true if the value is a boolean false.  Note
 * that a null is still false.

 *
 * @author Jeff Schnitzer <jeff@infohazard.org>
 */
public class IfFalse extends ValueIf<Boolean>
{
	@Override
	public boolean matchesValue(Boolean value) {
		return value != null && !value;
	}
}


text:
#include "channels/rdpdr/rdpdr-messages.h"
#include "channels/rdpdr/rdpdr.h"
#include "rdp.h"
#include "settings.h"

#include <freerdp/channels/rdpdr.h>
#include <guacamole/client.h>
#include <winpr/stream.h>

#include <stdlib.h>
#include <string.h>

/**
 * Sends a Client Announce Reply message. The Client Announce Reply message is
 * required to be sent in response to the Server Announce Request message. See:
 *
 * https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rdpefs/d6fe6d1b-c145-4a6f-99aa-4fe3cdcea398
 *
 * @param svc
 *     The guac_rdp_common_svc representing the static virtual channel being
 *     used for RDPDR.
 *
 * @param major
 *     The major version of the RDPDR protocol in use. This value must always
 *     be 1.
 *
 * @param minor
 *     The minor version of the RDPDR protocol in use. This value must be
 *     either 2, 5, 10, 12, or 13.
 *
 * @param client_id
 *     The client ID received in the Server Announce Request, or a randomly
 *     generated ID.
 */
static void guac_rdpdr_send_client_announce_reply(guac_rdp_common_svc* svc,
        unsigned int major, unsigned int minor, unsigned int client_id) {

    wStream* output_stream = Stream_New(NULL, 12);

    /* Write header */
    Stream_Write_UINT16(output_stream, RDPDR_CTYP_CORE);
    Stream_Write_UINT16(output_stream, PAKID_CORE_CLIENTID_CONFIRM);

    /* Write content */
    Stream_Write_UINT16(output_stream, major);
    Stream_Write_UINT16(output_stream, minor);
    Stream_Write_UINT32(output_stream, client_id);

    guac_rdp_common_svc_write(svc, output_stream);

}

/**
 * Sends a Client Name Request message. The Client Name Request message is used
 * by the client to announce its own name. See:
 *
 * https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rdpefs/902497f1-3b1c-4aee-95f8-1668f9b7b7d2
 *
 * @param svc
 *     The guac_rdp_common_svc representing the static virtual channel being
 *     used for RDPDR.
 *
 * @param name
 *     The name that should be used for the client.
 */
static void guac_rdpdr_send_client_name_request(guac_rdp_common_svc* svc,
        const char* name) {

    int name_bytes = strlen(name) + 1;
    wStream* output_stream = Stream_New(NULL, 16 + name_bytes);

    /* Write header */
    Stream_Write_UINT16(output_stream, RDPDR_CTYP_CORE);
    Stream_Write_UINT16(output_stream, PAKID_CORE_CLIENT_NAME);

    /* Write content */
    Stream_Write_UINT32(output_stream, 0); /* ASCII */
    Stream_Write_UINT32(output_stream, 0); /* 0 required by RDPDR spec */
    Stream_Write_UINT32(output_stream, name_bytes);
    Stream_Write(output_stream, name, name_bytes);

    guac_rdp_common_svc_write(svc, output_stream);

}

/**
 * Sends a Client Core Capability Response message. The Client Core Capability
 * Response message is used to announce the client's capabilities, in response
 * to receiving the server's capabilities via a Server Core Capability Request.
 * See:
 *
 * https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rdpefs/f513bf87-cca0-488a-ac5c-18cf18f4a7e1
 *
 * @param svc
 *     The guac_rdp_common_svc representing the static virtual channel being
 *     used for RDPDR.
 */
static void guac_rdpdr_send_client_capability(guac_rdp_common_svc* svc) {

    wStream* output_stream = Stream_New(NULL, 256);
    guac_client_log(svc->client, GUAC_LOG_DEBUG, "Sending capabilities...");

    /* Write header */
    Stream_Write_UINT16(output_stream, RDPDR_CTYP_CORE);
    Stream_Write_UINT16(output_stream, PAKID_CORE_CLIENT_CAPABILITY);

    /* Capability count + padding */
    Stream_Write_UINT16(output_stream, 3);
    Stream_Write_UINT16(output_stream, 0); /* Padding */

    /* General capability header */
    Stream_Write_UINT16(output_stream, CAP_GENERAL_TYPE);
    Stream_Write_UINT16(output_stream, 44);
    Stream_Write_UINT32(output_stream, GENERAL_CAPABILITY_VERSION_02);

    /* General capability data */
    Stream_Write_UINT32(output_stream, GUAC_OS_TYPE);                /* osType - required to be ignored */
    Stream_Write_UINT32(output_stream, 0);                           /* osVersion */
    Stream_Write_UINT16(output_stream, 1);                           /* protocolMajor - must be set to 1 */
    Stream_Write_UINT16(output_stream, RDPDR_MINOR_RDP_VERSION_5_2); /* protocolMinor */
    Stream_Write_UINT32(output_stream, 0xFFFF);                      /* ioCode1 */
    Stream_Write_UINT32(output_stream, 0);                           /* ioCode2 */
    Stream_Write_UINT32(output_stream,
                                      RDPDR_DEVICE_REMOVE_PDUS
                                    | RDPDR_CLIENT_DISPLAY_NAME_PDU
                                    | RDPDR_USER_LOGGEDON_PDU); /* extendedPDU */
    Stream_Write_UINT32(output_stream, 0);                      /* extraFlags1 */
    Stream_Write_UINT32(output_stream, 0);                      /* extraFlags2 */
    Stream_Write_UINT32(output_stream, 0);                      /* SpecialTypeDeviceCap */

    /* Printer support header */
    Stream_Write_UINT16(output_stream, CAP_PRINTER_TYPE);
    Stream_Write_UINT16(output_stream, 8);
    Stream_Write_UINT32(output_stream, PRINT_CAPABILITY_VERSION_01);

    /* Drive support header */
    Stream_Write_UINT16(output_stream, CAP_DRIVE_TYPE);
    Stream_Write_UINT16(output_stream, 8);
    Stream_Write_UINT32(output_stream, DRIVE_CAPABILITY_VERSION_02);

    guac_rdp_common_svc_write(svc, output_stream);
    guac_client_log(svc->client, GUAC_LOG_DEBUG, "Capabilities sent.");

}

/**
 * Sends a Client Device List Announce Request message. The Client Device List
 * Announce Request message is used by the client to enumerate all devices
 * which should be made available within the RDP session via RDPDR. See:
 *
 * https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rdpefs/10ef9ada-cba2-4384-ab60-7b6290ed4a9a
 *
 * @param svc
 *     The guac_rdp_common_svc representing the static virtual channel being
 *     used for RDPDR.
 */
static void guac_rdpdr_send_client_device_list_announce_request(guac_rdp_common_svc* svc) {

    guac_rdpdr* rdpdr = (guac_rdpdr*) svc->data;

    /* Calculate number of bytes needed for the stream */
    int streamBytes = 16;
    for (int i=0; i < rdpdr->devices_registered; i++)
        streamBytes += rdpdr->devices[i].device_announce_len;

    /* Allocate the stream */
    wStream* output_stream = Stream_New(NULL, streamBytes);

    /* Write header */
    Stream_Write_UINT16(output_stream, RDPDR_CTYP_CORE);
    Stream_Write_UINT16(output_stream, PAKID_CORE_DEVICELIST_ANNOUNCE);

    /* Get the stream for each of the devices. */
    Stream_Write_UINT32(output_stream, rdpdr->devices_registered);
    for (int i=0; i<rdpdr->devices_registered; i++) {

        Stream_Write(output_stream,
                Stream_Buffer(rdpdr->devices[i].device_announce),
                rdpdr->devices[i].device_announce_len);

        guac_client_log(svc->client, GUAC_LOG_DEBUG, "Registered device %i (%s)",
                rdpdr->devices[i].device_id, rdpdr->devices[i].device_name);

    }

    guac_rdp_common_svc_write(svc, output_stream);
    guac_client_log(svc->client, GUAC_LOG_DEBUG, "All supported devices sent.");

}

void guac_rdpdr_process_server_announce(guac_rdp_common_svc* svc,
        wStream* input_stream) {

    unsigned int major, minor, client_id;

    /* Stream should contain at least 8 bytes (UINT16 + UINT16 + UINT32) */
    if (Stream_GetRemainingLength(input_stream) < 8) {
        guac_client_log(svc->client, GUAC_LOG_WARNING, "Server Announce "
                "Request PDU does not contain the expected number of bytes. "
                "Device redirection may not work as expected.");
        return;
    }

    Stream_Read_UINT16(input_stream, major);
    Stream_Read_UINT16(input_stream, minor);
    Stream_Read_UINT32(input_stream, client_id);

    /* Must choose own client ID if minor not >= 12 */
    if (minor < 12)
        client_id = random() & 0xFFFF;

    guac_client_log(svc->client, GUAC_LOG_INFO, "Connected to RDPDR %u.%u as client 0x%04x", major, minor, client_id);

    /* Respond to announce */
    guac_rdpdr_send_client_announce_reply(svc, major, minor, client_id);

    /* Name request */
    guac_rdpdr_send_client_name_request(svc, ((guac_rdp_client*) svc->client->data)->settings->client_name);

}

void guac_rdpdr_process_clientid_confirm(guac_rdp_common_svc* svc,
        wStream* input_stream) {
    guac_client_log(svc->client, GUAC_LOG_DEBUG, "Client ID confirmed");
}

void guac_rdpdr_process_device_reply(guac_rdp_common_svc* svc,
        wStream* input_stream) {

    guac_rdpdr* rdpdr = (guac_rdpdr*) svc->data;

    unsigned int device_id, ntstatus;
    int severity, c, n, facility, code;

    /* Stream should contain at least 8 bytes (UINT32 + UINT32 ) */
    if (Stream_GetRemainingLength(input_stream) < 8) {
        guac_client_log(svc->client, GUAC_LOG_WARNING, "Server Device Announce"
                "Response PDU does not contain the expected number of bytes."
                "Device redirection may not work as expected.");
        return;
    }

    Stream_Read_UINT32(input_stream, device_id);
    Stream_Read_UINT32(input_stream, ntstatus);

    severity = (ntstatus & 0xC0000000) >> 30;
    c        = (ntstatus & 0x20000000) >> 29;
    n        = (ntstatus & 0x10000000) >> 28;
    facility = (ntstatus & 0x0FFF0000) >> 16;
    code     =  ntstatus & 0x0000FFFF;

    /* Log error / information */
    if (device_id < rdpdr->devices_registered) {

        if (severity == 0x0)
            guac_client_log(svc->client, GUAC_LOG_DEBUG, "Device %i (%s) connected successfully",
                    device_id, rdpdr->devices[device_id].device_name);

        else
            guac_client_log(svc->client, GUAC_LOG_ERROR, "Problem connecting device %i (%s): "
                    "severity=0x%x, c=0x%x, n=0x%x, facility=0x%x, code=0x%x",
                     device_id, rdpdr->devices[device_id].device_name,
                     severity,      c,      n,      facility,      code);

    }

    else
        guac_client_log(svc->client, GUAC_LOG_ERROR, "Unknown device ID: 0x%08x", device_id);

}

void guac_rdpdr_process_device_iorequest(guac_rdp_common_svc* svc,
        wStream* input_stream) {

    guac_rdpdr* rdpdr = (guac_rdpdr*) svc->data;
    guac_rdpdr_iorequest iorequest;

    /* Check to make sure the Stream contains at least 20 bytes (5 x UINT32 ). */
    if (Stream_GetRemainingLength(input_stream) < 20) {
        guac_client_log(svc->client, GUAC_LOG_WARNING, "Device I/O Request PDU "
                "does not contain the expected number of bytes. Device "
                "redirection may not work as expected.");
        return;
    }

    /* Read header */
    Stream_Read_UINT32(input_stream, iorequest.device_id);
    Stream_Read_UINT32(input_stream, iorequest.file_id);
    Stream_Read_UINT32(input_stream, iorequest.completion_id);
    Stream_Read_UINT32(input_stream, iorequest.major_func);
    Stream_Read_UINT32(input_stream, iorequest.minor_func);

    /* If printer, run printer handlers */
    if (iorequest.device_id >= 0 && iorequest.device_id < rdpdr->devices_registered) {

        /* Call handler on device */
        guac_rdpdr_device* device = &(rdpdr->devices[iorequest.device_id]);
        device->iorequest_handler(svc, device, &iorequest, input_stream);

    }

    else
        guac_client_log(svc->client, GUAC_LOG_ERROR, "Unknown device ID: "
                "0x%08x", iorequest.device_id);

}

void guac_rdpdr_process_server_capability(guac_rdp_common_svc* svc,
        wStream* input_stream) {

    int count;
    int i;

    /* Check to make sure the Stream has at least 4 bytes (UINT16 + 2) */
    if (Stream_GetRemainingLength(input_stream) < 4) {
        guac_client_log(svc->client, GUAC_LOG_WARNING, "Server Core Capability "
                "Request PDU does not contain the expected number of bytes."
                "Device redirection may not work as expected.");
        return;
    }

    /* Read header */
    Stream_Read_UINT16(input_stream, count);
    Stream_Seek(input_stream, 2);

    /* Parse capabilities */
    for (i=0; i<count; i++) {

        int type;
        int length;

        /* Make sure Stream has at least 4 bytes (UINT16 + UINT16) */
        if (Stream_GetRemainingLength(input_stream) < 4) {
            guac_client_log(svc->client, GUAC_LOG_WARNING, "Server Core "
                    "Capability Request PDU does not contain the expected "
                    "number of bytes. Device redirection may not work as "
                    "expected.");
            break;
        }

        Stream_Read_UINT16(input_stream, type);
        Stream_Read_UINT16(input_stream, length);

        /* Make sure Stream has required length remaining for Seek below. */
        if (Stream_GetRemainingLength(input_stream) < (length - 4)) {
            guac_client_log(svc->client, GUAC_LOG_WARNING, "Server Core "
                    "Capability Request PDU does not contain the expected "
                    "number of bytes. Device redirection may not work as "
                    "expected.");
            break;
        }

        /* Ignore all for now */
        guac_client_log(svc->client, GUAC_LOG_DEBUG, "Ignoring server capability set type=0x%04x, length=%i", type, length);
        Stream_Seek(input_stream, length - 4);

    }

    /* Send own capabilities */
    guac_rdpdr_send_client_capability(svc);

}

void guac_rdpdr_process_user_loggedon(guac_rdp_common_svc* svc,
        wStream* input_stream) {

    guac_client_log(svc->client, GUAC_LOG_INFO, "RDPDR user logged on");
    guac_rdpdr_send_client_device_list_announce_request(svc);

}

void guac_rdpdr_process_prn_cache_data(guac_rdp_common_svc* svc,
        wStream* input_stream) {
    guac_client_log(svc->client, GUAC_LOG_DEBUG, "Ignoring printer cached configuration data");
}

void guac_rdpdr_process_prn_using_xps(guac_rdp_common_svc* svc,
        wStream* input_stream) {
    guac_client_log(svc->client, GUAC_LOG_WARNING, "Printer unexpectedly switched to XPS mode");
}


text:
package org.jdfs.client.handler;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 处理链,用于串联多个处理
 *
 * @author James Quan
 * @version 2015年2月25日 上午10:58:38
 */
public class ActionChain {

	private List<Action> actions;
	private int currentPosition = 0;
	private String errorMessage = null;
	private Throwable error = null;

	/**
	 * 返回处理链中所包含的处理集合,一定不为{@code null}
	 *
	 * @return
	 */
	public Action[] getActions() {
		return actions == null ? new AbstractServerAction[0] : actions
				.toArray(new AbstractServerAction[0]);
	}

	/**
	 * 设置处理链中所包含的处理集合
	 *
	 * @param actions
	 */
	public void setActions(Action[] actions) {
		if (actions == null || actions.length == 0) {
			this.actions = null;
		} else {
			this.actions = new ArrayList<Action>(actions.length);
			for (Action action : actions) {
				this.actions.add(action);
			}
		}
	}

	/**
	 * 向处理链的末尾添加处理
	 *
	 * @param action
	 */
	public void addAction(Action action) {
		if (actions == null) {
			actions = new ArrayList<Action>();
		}
		actions.add(action);
	}

	/**
	 * 执行处理操作
	 *
	 * @param request
	 *            操作的请求数据
	 * @param data
	 *            操作的上下文
	 * @return 操作的返回值
	 */
	public Object doAction(Object request, Map<String, Object> data) {
		if (hasError()) {
			throw new RuntimeException(errorMessage, error);
		}
		Action action = null;
		if (actions != null && actions.size() > currentPosition) {
			action = actions.get(currentPosition);
			currentPosition++;
		}
		Object result = null;
		try {
			result = action == null ? request : action.process(request, data,
					this);
		} catch (Throwable t) {
			error = t;
			errorMessage = t.getMessage();
		}
		if (hasError()) {
			throw new RuntimeException(errorMessage, error);
		} else {
			return result;
		}
	}

	protected boolean hasError() {
		return errorMessage != null || error != null;
	}

	/**
	 * 执行处理操作出错时执行的回调函数
	 *
	 * @param message
	 * @param error
	 */
	public void throwException(String message, Throwable error) {
		this.errorMessage = message;
		this.error = error;
	}
}


text:
package com.odinarts.android.storagescanner.db;

import android.provider.BaseColumns;

public class ExtensionsContract {
    // To prevent accidental instantiation.
    private ExtensionsContract() {}

    public class ExtensionsEntry implements BaseColumns {
        public static final String TABLE_NAME = "extensions";
        public static final String COLUMN_EXTENSION = "extension";
        public static final String COLUMN_COUNT = "count";
    }
}


text:
CREATE TABLE [dbo].[Flights]
(
    [Name] NCHAR(10) NOT NULL,
    [SourceCity] NCHAR(10) NOT NULL,
    [TargetCity] NCHAR(10) NOT NULL,
    [TakeoffTime] TIME NULL,
    [LandingTime] TIME NULL,
    CONSTRAINT [FK_SourceCity_To_Cities] FOREIGN KEY ([SourceCity]) REFERENCES [Cities]([Name]),
    CONSTRAINT [FK_TargetCity_To_Cities] FOREIGN KEY ([TargetCity]) REFERENCES [Cities]([Name]),
    PRIMARY KEY ([Name]),
)


text:
    <toolbar name="model.name" display-name="model.displayName" actions='actions'></toolbar>

<form novalidate name="artistForm" role="form">
    <fieldset>
        <input id="id" class="form-control" type="hidden" ng-model="currentRecord.id"/>

        Name

            <input id="name" name="name" class="form-control" type="text" ng-model="currentRecord.name" ng-required="true" />

    </fieldset>
</form>


text:
<?php

declare(strict_types=1);

namespace Incoming\Structure;

use ArrayAccess;
use Countable;
use IteratorAggregate;

/**
 * A compound interface defining the external interface of a structure type,
 * which is the union of multiple native data-structure interfaces.
 */
interface Structure extends ArrayAccess, Countable, IteratorAggregate
{
}


text:
typedef enum {
    drop_new,
    drop_old,
    return_error,
} on_overflov_t;

typedef enum {
    direction_none,
    direction_next,
    direction_prev,
} direction_t;

typedef int64_t vptr_t;

class ShmBufferExData {
public:
    constexpr static const uint32_t MaxReaderCount = 3;
    typedef struct {
        vptr_t pos;
        vptr_t lost;
    } reader_info_t;

    union {
        struct {
            ShmBase::shm_header_t header;
            size_t buffer_size;
            volatile uint32_t head;
            volatile uint32_t tail;
            volatile uint64_t head_offset;
            volatile uint64_t tail_offset;
            volatile shm_record_size_t last_record_size;
            volatile uint64_t total_drop_count;
            volatile uint64_t total_error_count;
            volatile uint64_t tmp_drop_count;
            volatile uint64_t tmp_drop_volume;
            volatile uint64_t tmp_count;
            volatile uint64_t tmp_volume;
            volatile uint64_t count;
            volatile uint64_t total_count;
            on_overflov_t on_overflow;
            reader_info_t reader[MaxReaderCount];
            bool drop_is_ok;
        };
        uint8_t fill_page[MEM_PAGE_SIZE];
    };
    uint8_t circular_data[];

    void Init(size_t _size) {
        buffer_size = _size - sizeof(ShmBufferExData);
        head = tail = 0;
        head_offset = tail_offset = 0;
        last_record_size = 0;
        tmp_drop_count = 0;
        tmp_drop_volume = 0;
        tmp_count = 0;
        tmp_volume = 0;
        count = 0;
        total_count = 0;
        total_drop_count = 0;
        total_error_count = 0;
        on_overflow = return_error;
        memset(reader, 0, sizeof(reader));
    }

    bool write(const uint8_t *data, const size_t data_size);
    void commit(const size_t data_size);
    size_t read(uint8_t *data, const size_t data_size);

    uint8_t *peek() {
        if (is_empty()) {
            return NULL;
        }
        return &circular_data[head];
    }

    void free_head(size_t _size) {
        head += _size;
        if (head >= buffer_size) {
            head -= buffer_size;
            head_offset += buffer_size;
        }
    }

    size_t capacity() const {
        return buffer_size - 1;
    }

    size_t data_size() const {
        if (head <= tail) {
            return tail - head;
        } else {
            return buffer_size - (head - tail);
        }
    }

    size_t get_used_bp() const {
        return data_size()*10000/capacity();
    }

    size_t free_size() const {
        return capacity() - data_size();
    }

    bool is_empty() const {
        return head == tail;
    }

    bool Push(const ShmChunks &chunks);

    bool Add(const uint8_t *data, shm_record_size_t size) {
        return Push(ShmChunks(data, size));
    }

    bool Pop(uint8_t *data, shm_record_size_t max_size, shm_record_size_t &size, bool delete_record = true);
    bool Get(vptr_t &pos, direction_t dir, uint8_t *data, shm_record_size_t max_size, shm_record_size_t &size);
    bool Get(vptr_t &pos, vptr_t &lost, uint8_t *data, shm_record_size_t max_size, shm_record_size_t &size);
    bool Get(int reader_index, uint8_t *data, shm_record_size_t max_size, shm_record_size_t &size);

    bool GetReaderInfo(int reader_index, reader_info_t &reader_info) {
        if (reader_index < 0 || reader_index >= MaxReaderCount) {
            return false;
        }
        reader_info = reader[reader_index];
        return true;
    }

    vptr_t GetBeginVptr() const {
        return head + head_offset;
    }

    vptr_t GetEndVptr() const {
        return tail + tail_offset;
    }

    vptr_t GetLastVptr() const {
        return tail + tail_offset - last_record_size;
    }

    vptr_t GetNextVptr(vptr_t pos) const {
        if (pos < GetBeginVptr()) {
            return GetBeginVptr();
        }
        if (pos >= GetEndVptr()) {
            return GetEndVptr();
        }
        const ShmBufferRecord *r = getRecord(pos);
        return pos + r->Size();
    }

    vptr_t GetPrevVptr(vptr_t pos) const {
        if (pos <= GetBeginVptr()) {
            return -1;
        }
        vptr_t end = GetEndVptr();
        if (pos > end) {
            return end;
        }
        if (pos == end) {
            return pos - last_record_size;
        } else {
            const ShmBufferRecord *r = getRecord(pos);
            return pos - r->PrevSize();
        }
    }

    const ShmBufferRecord *getRecord(vptr_t vptr) const {
        return (const ShmBufferRecord *) (circular_data + (vptr - head_offset));
    }

    void TransferDrops(HistoryCounter &drop, HistoryCounter &error) {
        drop.AddBatch(tmp_drop_count, tmp_drop_volume);
        if (!drop_is_ok) {
            error.AddBatch(tmp_drop_count, tmp_drop_volume);
        }
        tmp_drop_count = 0;
        tmp_drop_volume = 0;
    }

    void TransferMsg(HistoryCounter &c) {
        c.AddBatch(tmp_count, tmp_volume);
        tmp_count = 0;
        tmp_volume = 0;
    }

protected:
    const ShmBufferRecord *getFirstRecord() {
        return (const ShmBufferRecord *) peek();
    }

    ShmBufferRecord *getNewRecord() {
        return (ShmBufferRecord *) (circular_data + tail);
    }

    bool dropFirstRecord() {
        const ShmBufferRecord *rec = getFirstRecord();
        if (rec == NULL) {
            return false;
        }
        ++tmp_drop_count;
        tmp_drop_volume += rec->Size();
        --count;
        ++total_drop_count;
        if (!drop_is_ok) {
            ++total_error_count;
        }
        free_head(rec->Size());
        return true;
    }

    bool dropFirstRecords(shm_record_size_t for_size) {
        while (free_size() < for_size) {
            if (!dropFirstRecord()) {
                return false;
            }
        }
        return true;
    }
};