metron-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nickwallen <...@git.apache.org>
Subject [GitHub] incubator-metron pull request #435: METRON-684: Decouple Timestamp calculati...
Date Fri, 03 Feb 2017 16:46:12 GMT
Github user nickwallen commented on a diff in the pull request:

    https://github.com/apache/incubator-metron/pull/435#discussion_r99368863
  
    --- Diff: metron-analytics/metron-profiler-client/src/main/java/org/apache/metron/profiler/client/stellar/Util.java
---
    @@ -0,0 +1,117 @@
    +/*
    + *
    + *  Licensed to the Apache Software Foundation (ASF) under one
    + *  or more contributor license agreements.  See the NOTICE file
    + *  distributed with this work for additional information
    + *  regarding copyright ownership.  The ASF licenses this file
    + *  to you under the Apache License, Version 2.0 (the
    + *  "License"); you may not use this file except in compliance
    + *  with the License.  You may obtain a copy of the License at
    + *
    + *      http://www.apache.org/licenses/LICENSE-2.0
    + *
    + *  Unless required by applicable law or agreed to in writing, software
    + *  distributed under the License is distributed on an "AS IS" BASIS,
    + *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + *  See the License for the specific language governing permissions and
    + *  limitations under the License.
    + *
    + */
    +package org.apache.metron.profiler.client.stellar;
    +
    +import org.apache.commons.lang.StringUtils;
    +import org.apache.metron.common.dsl.Context;
    +import org.apache.metron.common.dsl.ParseException;
    +import org.apache.metron.common.utils.ConversionUtils;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.util.Collections;
    +import java.util.HashMap;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.stream.Collectors;
    +import java.util.stream.Stream;
    +
    +import static java.lang.String.format;
    +import static org.apache.metron.common.dsl.Context.Capabilities.GLOBAL_CONFIG;
    +
    +public class Util {
    +  private static final Logger LOG = LoggerFactory.getLogger(Util.class);
    +
    +  /**
    +   * Ensure that the required capabilities are defined.
    +   * @param context The context to validate.
    +   * @param required The required capabilities.
    +   * @throws IllegalStateException if all of the required capabilities are not present
in the Context.
    +   */
    +  public static void validateCapabilities(Context context, Context.Capabilities[] required)
throws IllegalStateException {
    +
    +    // collect the name of each missing capability
    +    String missing = Stream
    +            .of(required)
    +            .filter(c -> !context.getCapability(c).isPresent())
    +            .map(c -> c.toString())
    +            .collect(Collectors.joining(", "));
    +
    +    if(StringUtils.isNotBlank(missing) || context == null) {
    +      throw new IllegalStateException("missing required context: " + missing);
    +    }
    +  }
    +  /**
    --- End diff --
    
    Minor spacing issues (1 empty line between methods) here and later in the file.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message