repo_name
stringlengths 7
104
| file_path
stringlengths 13
198
| context
stringlengths 67
7.15k
| import_statement
stringlengths 16
4.43k
| code
stringlengths 40
6.98k
| prompt
stringlengths 227
8.27k
| next_line
stringlengths 8
795
|
---|---|---|---|---|---|---|
apache/maven-enforcer | enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/utils/TestArtifactMatcher.java | // Path: enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/utils/ArtifactMatcher.java
// public static class Pattern
// {
// private String pattern;
//
// private String[] parts;
//
// public Pattern( String pattern )
// {
// if ( pattern == null )
// {
// throw new NullPointerException( "pattern" );
// }
//
// this.pattern = pattern;
//
// parts = pattern.split( ":", 7 );
//
// if ( parts.length == 7 )
// {
// throw new IllegalArgumentException( "Pattern contains too many delimiters." );
// }
//
// for ( String part : parts )
// {
// if ( "".equals( part ) )
// {
// throw new IllegalArgumentException( "Pattern or its part is empty." );
// }
// }
// }
//
// public boolean match( Artifact artifact )
// throws InvalidVersionSpecificationException
// {
// if ( artifact == null )
// {
// throw new NullPointerException( "artifact" );
// }
//
// switch ( parts.length )
// {
// case 6:
// String classifier = artifact.getClassifier();
// if ( !matches( parts[5], classifier ) )
// {
// return false;
// }
// case 5:
// String scope = artifact.getScope();
// if ( scope == null || scope.equals( "" ) )
// {
// scope = Artifact.SCOPE_COMPILE;
// }
//
// if ( !matches( parts[4], scope ) )
// {
// return false;
// }
// case 4:
// String type = artifact.getType();
// if ( type == null || type.equals( "" ) )
// {
// type = "jar";
// }
//
// if ( !matches( parts[3], type ) )
// {
// return false;
// }
//
// case 3:
// if ( !matches( parts[2], artifact.getVersion() ) )
// {
// // CHECKSTYLE_OFF: LineLength
// if ( !AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( parts[2] ),
// new DefaultArtifactVersion(
// artifact.getVersion() ) ) )
// // CHECKSTYLE_ON: LineLength
// {
// return false;
// }
// }
//
// case 2:
// if ( !matches( parts[1], artifact.getArtifactId() ) )
// {
// return false;
// }
// case 1:
// return matches( parts[0], artifact.getGroupId() );
// default:
// throw new AssertionError();
// }
// }
//
// private boolean matches( String expression, String input )
// {
// String regex =
// expression.replace( ".", "\\." ).replace( "*", ".*" ).replace( ":", "\\:" ).replace( '?', '.' )
// .replace( "[", "\\[" ).replace( "]", "\\]" ).replace( "(", "\\(" ).replace( ")", "\\)" );
//
// // TODO: Check if this can be done better or prevented earlier.
// if ( input == null )
// {
// input = "";
// }
//
// return java.util.regex.Pattern.matches( regex, input );
// }
//
// @Override
// public String toString()
// {
// return pattern;
// }
// }
| import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.handler.DefaultArtifactHandler;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.plugins.enforcer.utils.ArtifactMatcher.Pattern;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Collection; | package org.apache.maven.plugins.enforcer.utils;
/*
* 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.
*/
public class TestArtifactMatcher
{
Collection<String> patterns = new ArrayList<>();
Collection<String> ignorePatterns = new ArrayList<>();
@Test
public void testPatternInvalidInput()
throws InvalidVersionSpecificationException
{
try
{ | // Path: enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/utils/ArtifactMatcher.java
// public static class Pattern
// {
// private String pattern;
//
// private String[] parts;
//
// public Pattern( String pattern )
// {
// if ( pattern == null )
// {
// throw new NullPointerException( "pattern" );
// }
//
// this.pattern = pattern;
//
// parts = pattern.split( ":", 7 );
//
// if ( parts.length == 7 )
// {
// throw new IllegalArgumentException( "Pattern contains too many delimiters." );
// }
//
// for ( String part : parts )
// {
// if ( "".equals( part ) )
// {
// throw new IllegalArgumentException( "Pattern or its part is empty." );
// }
// }
// }
//
// public boolean match( Artifact artifact )
// throws InvalidVersionSpecificationException
// {
// if ( artifact == null )
// {
// throw new NullPointerException( "artifact" );
// }
//
// switch ( parts.length )
// {
// case 6:
// String classifier = artifact.getClassifier();
// if ( !matches( parts[5], classifier ) )
// {
// return false;
// }
// case 5:
// String scope = artifact.getScope();
// if ( scope == null || scope.equals( "" ) )
// {
// scope = Artifact.SCOPE_COMPILE;
// }
//
// if ( !matches( parts[4], scope ) )
// {
// return false;
// }
// case 4:
// String type = artifact.getType();
// if ( type == null || type.equals( "" ) )
// {
// type = "jar";
// }
//
// if ( !matches( parts[3], type ) )
// {
// return false;
// }
//
// case 3:
// if ( !matches( parts[2], artifact.getVersion() ) )
// {
// // CHECKSTYLE_OFF: LineLength
// if ( !AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( parts[2] ),
// new DefaultArtifactVersion(
// artifact.getVersion() ) ) )
// // CHECKSTYLE_ON: LineLength
// {
// return false;
// }
// }
//
// case 2:
// if ( !matches( parts[1], artifact.getArtifactId() ) )
// {
// return false;
// }
// case 1:
// return matches( parts[0], artifact.getGroupId() );
// default:
// throw new AssertionError();
// }
// }
//
// private boolean matches( String expression, String input )
// {
// String regex =
// expression.replace( ".", "\\." ).replace( "*", ".*" ).replace( ":", "\\:" ).replace( '?', '.' )
// .replace( "[", "\\[" ).replace( "]", "\\]" ).replace( "(", "\\(" ).replace( ")", "\\)" );
//
// // TODO: Check if this can be done better or prevented earlier.
// if ( input == null )
// {
// input = "";
// }
//
// return java.util.regex.Pattern.matches( regex, input );
// }
//
// @Override
// public String toString()
// {
// return pattern;
// }
// }
// Path: enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/utils/TestArtifactMatcher.java
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.handler.DefaultArtifactHandler;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.plugins.enforcer.utils.ArtifactMatcher.Pattern;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Collection;
package org.apache.maven.plugins.enforcer.utils;
/*
* 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.
*/
public class TestArtifactMatcher
{
Collection<String> patterns = new ArrayList<>();
Collection<String> ignorePatterns = new ArrayList<>();
@Test
public void testPatternInvalidInput()
throws InvalidVersionSpecificationException
{
try
{ | new Pattern( null ); |
apache/maven-enforcer | enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireSnapshotVersion.java | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
| import org.apache.maven.artifact.Artifact;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; | package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* This rule checks that the current project is not a release.
*/
public class RequireSnapshotVersion
extends AbstractNonCacheableEnforcerRule
{
/**
* Allows this rule to fail when the parent is defined as a release.
*/
private boolean failWhenParentIsRelease = true;
@Override | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
// Path: enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireSnapshotVersion.java
import org.apache.maven.artifact.Artifact;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* This rule checks that the current project is not a release.
*/
public class RequireSnapshotVersion
extends AbstractNonCacheableEnforcerRule
{
/**
* Allows this rule to fail when the parent is defined as a release.
*/
private boolean failWhenParentIsRelease = true;
@Override | public void execute( EnforcerRuleHelper helper ) |
apache/maven-enforcer | enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestBannedRepositories.java | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
| import java.util.ArrayList;
import java.util.List;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.MavenArtifactRepository;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.fail; | package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* Test the "banned repositories" rule.
*
* @author <a href="mailto:[email protected]">Simon Wang</a>
*/
public class TestBannedRepositories
{ | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
// Path: enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestBannedRepositories.java
import java.util.ArrayList;
import java.util.List;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.MavenArtifactRepository;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.fail;
package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* Test the "banned repositories" rule.
*
* @author <a href="mailto:[email protected]">Simon Wang</a>
*/
public class TestBannedRepositories
{ | private EnforcerRuleHelper helper; |
apache/maven-enforcer | enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireReleaseVersion.java | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
| import org.apache.maven.artifact.Artifact;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; | package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* This rule checks that the current project is not a snapshot.
*
* @author <a href="mailto:[email protected]">Brian Fox</a>
*/
public class RequireReleaseVersion
extends AbstractNonCacheableEnforcerRule
{
/**
* Allows this rule to fail when the parent is defined as a snapshot.
*
* @parameter
*
* @see {@link #setFailWhenParentIsSnapshot(boolean)}
* @see {@link #isFailWhenParentIsSnapshot()}
*/
private boolean failWhenParentIsSnapshot = true;
@Override | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
// Path: enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireReleaseVersion.java
import org.apache.maven.artifact.Artifact;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* This rule checks that the current project is not a snapshot.
*
* @author <a href="mailto:[email protected]">Brian Fox</a>
*/
public class RequireReleaseVersion
extends AbstractNonCacheableEnforcerRule
{
/**
* Allows this rule to fail when the parent is defined as a snapshot.
*
* @parameter
*
* @see {@link #setFailWhenParentIsSnapshot(boolean)}
* @see {@link #isFailWhenParentIsSnapshot()}
*/
private boolean failWhenParentIsSnapshot = true;
@Override | public void execute( EnforcerRuleHelper theHelper ) |
apache/maven-enforcer | enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/ReactorModuleConvergence.java | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
| import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
import org.codehaus.plexus.util.StringUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Dependency;
import org.apache.maven.plugin.logging.Log;
| package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* This rule will check if a multi module build will follow the best practices.
*
* @author Karl-Heinz Marbaise
* @since 1.4
*/
public class ReactorModuleConvergence
extends AbstractNonCacheableEnforcerRule
{
private static final String MODULE_TEXT = " module: ";
private boolean ignoreModuleDependencies = false;
private Log logger;
@Override
| // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
// Path: enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/ReactorModuleConvergence.java
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
import org.codehaus.plexus.util.StringUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Dependency;
import org.apache.maven.plugin.logging.Log;
package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* This rule will check if a multi module build will follow the best practices.
*
* @author Karl-Heinz Marbaise
* @since 1.4
*/
public class ReactorModuleConvergence
extends AbstractNonCacheableEnforcerRule
{
private static final String MODULE_TEXT = " module: ";
private boolean ignoreModuleDependencies = false;
private Log logger;
@Override
| public void execute( EnforcerRuleHelper helper )
|
apache/maven-enforcer | enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireNoRepositories.java | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
| import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.execution.MavenSession;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.apache.maven.execution.ProjectDependencyGraph;
import java.util.ArrayList;
import org.apache.maven.model.Model;
import org.apache.maven.model.Repository;
import org.apache.maven.model.RepositoryPolicy;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.List;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import static org.junit.jupiter.api.Assertions.assertThrows; | package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* Test the "require no repositories" rule.
*
* @author <a href="mailto:[email protected]">Brett Porter</a>
* @author <a href="mailto:[email protected]">Karl Heinz Marbaise</a>
*/
public class TestRequireNoRepositories
{ | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
// Path: enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireNoRepositories.java
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.execution.MavenSession;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.apache.maven.execution.ProjectDependencyGraph;
import java.util.ArrayList;
import org.apache.maven.model.Model;
import org.apache.maven.model.Repository;
import org.apache.maven.model.RepositoryPolicy;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.List;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import static org.junit.jupiter.api.Assertions.assertThrows;
package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* Test the "require no repositories" rule.
*
* @author <a href="mailto:[email protected]">Brett Porter</a>
* @author <a href="mailto:[email protected]">Karl Heinz Marbaise</a>
*/
public class TestRequireNoRepositories
{ | private EnforcerRuleHelper helper; |
apache/maven-enforcer | enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/RequireUpperBoundDepsTest.java | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
| import org.junit.jupiter.api.Test;
import java.io.IOException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.plugin.testing.ArtifactStubFactory;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.junit.jupiter.api.Assertions.fail; | package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
public class RequireUpperBoundDepsTest
{
@Test
public void testRule()
throws IOException
{
ArtifactStubFactory factory = new ArtifactStubFactory();
MockProject project = new MockProject(); | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
// Path: enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/RequireUpperBoundDepsTest.java
import org.junit.jupiter.api.Test;
import java.io.IOException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.plugin.testing.ArtifactStubFactory;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.junit.jupiter.api.Assertions.fail;
package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
public class RequireUpperBoundDepsTest
{
@Test
public void testRule()
throws IOException
{
ArtifactStubFactory factory = new ArtifactStubFactory();
MockProject project = new MockProject(); | EnforcerRuleHelper helper = EnforcerTestUtils.getHelper( project ); |
apache/maven-enforcer | enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireFilesSize.java | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRule.java
// public interface EnforcerRule
// {
//
// /**
// * This is the interface into the rule. This method should throw an exception
// * containing a reason message if the rule fails the check. The plugin will
// * then decide based on the fail flag if it should stop or just log the
// * message as a warning.
// *
// * @param helper The helper provides access to the log, MavenSession and has
// * helpers to get common components. It is also able to lookup components
// * by class name.
// *
// * @throws EnforcerRuleException the enforcer rule exception
// */
// void execute( @Nonnull EnforcerRuleHelper helper )
// throws EnforcerRuleException;
//
// /**
// * This method tells the enforcer if the rule results may be cached. If the result is true,
// * the results will be remembered for future executions in the same build (ie children). Subsequent
// * iterations of the rule will be queried to see if they are also cacheable. This will allow the rule to be
// * uncached further down the tree if needed.
// *
// * @return <code>true</code> if rule is cacheable
// */
// boolean isCacheable();
//
// /**
// * If the rule is cacheable and the same id is found in the cache, the stored results are passed to this method to
// * allow double checking of the results. Most of the time this can be done by generating unique ids, but sometimes
// * the results of objects returned by the helper need to be queried. You may for example, store certain objects in
// * your rule and then query them later.
// *
// * @param cachedRule the last cached instance of the rule. This is to be used by the rule to
// * potentially determine if the results are still valid (ie if the configuration has been overridden)
// *
// * @return <code>true</code> if the stored results are valid for the same id.
// */
// boolean isResultValid( @Nonnull EnforcerRule cachedRule );
//
// /**
// * If the rule is to be cached, this id is used as part of the key. This can allow rules to take parameters
// * that allow multiple results of the same rule to be cached.
// *
// * @return id to be used by the enforcer to determine uniqueness of cache results. The ids only need to be unique
// * within a given rule implementation as the full key will be [classname]-[id]
// */
// @Nullable
// String getCacheId();
//
// }
//
// Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
| import java.io.File;
import org.apache.maven.enforcer.rule.api.EnforcerRule;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; | package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* Rule to validate the main artifact is within certain size constraints.
*
* @author brianf
* @author Roman Stumm
*/
public class RequireFilesSize
extends AbstractRequireFiles
{
private static final long MAXSIZE = 10000;
/** the max size allowed. */
private long maxsize = MAXSIZE;
/** the min size allowed. */
private long minsize = 0;
/** The error msg. */
private String errorMsg;
/** The log. */
private Log log;
@Override | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRule.java
// public interface EnforcerRule
// {
//
// /**
// * This is the interface into the rule. This method should throw an exception
// * containing a reason message if the rule fails the check. The plugin will
// * then decide based on the fail flag if it should stop or just log the
// * message as a warning.
// *
// * @param helper The helper provides access to the log, MavenSession and has
// * helpers to get common components. It is also able to lookup components
// * by class name.
// *
// * @throws EnforcerRuleException the enforcer rule exception
// */
// void execute( @Nonnull EnforcerRuleHelper helper )
// throws EnforcerRuleException;
//
// /**
// * This method tells the enforcer if the rule results may be cached. If the result is true,
// * the results will be remembered for future executions in the same build (ie children). Subsequent
// * iterations of the rule will be queried to see if they are also cacheable. This will allow the rule to be
// * uncached further down the tree if needed.
// *
// * @return <code>true</code> if rule is cacheable
// */
// boolean isCacheable();
//
// /**
// * If the rule is cacheable and the same id is found in the cache, the stored results are passed to this method to
// * allow double checking of the results. Most of the time this can be done by generating unique ids, but sometimes
// * the results of objects returned by the helper need to be queried. You may for example, store certain objects in
// * your rule and then query them later.
// *
// * @param cachedRule the last cached instance of the rule. This is to be used by the rule to
// * potentially determine if the results are still valid (ie if the configuration has been overridden)
// *
// * @return <code>true</code> if the stored results are valid for the same id.
// */
// boolean isResultValid( @Nonnull EnforcerRule cachedRule );
//
// /**
// * If the rule is to be cached, this id is used as part of the key. This can allow rules to take parameters
// * that allow multiple results of the same rule to be cached.
// *
// * @return id to be used by the enforcer to determine uniqueness of cache results. The ids only need to be unique
// * within a given rule implementation as the full key will be [classname]-[id]
// */
// @Nullable
// String getCacheId();
//
// }
//
// Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
// Path: enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireFilesSize.java
import java.io.File;
import org.apache.maven.enforcer.rule.api.EnforcerRule;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* Rule to validate the main artifact is within certain size constraints.
*
* @author brianf
* @author Roman Stumm
*/
public class RequireFilesSize
extends AbstractRequireFiles
{
private static final long MAXSIZE = 10000;
/** the max size allowed. */
private long maxsize = MAXSIZE;
/** the min size allowed. */
private long minsize = 0;
/** The error msg. */
private String errorMsg;
/** The log. */
private Log log;
@Override | public void execute( EnforcerRuleHelper helper ) |
apache/maven-enforcer | enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequirePrerequisite.java | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
| import java.util.List;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.model.Prerequisites;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
| package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* @author Robert Scholte
* @since 1.3
*/
public class RequirePrerequisite
extends AbstractNonCacheableEnforcerRule
{
/**
* Only the projects with one of these packagings will be enforced to have the correct prerequisite.
*
* @since 1.4
*/
private List<String> packagings;
/**
* Can either be version or a range, e.g. {@code 2.2.1} or {@code [2.2.1,)}
*/
private String mavenVersion;
/**
* Set the mavenVersion Can either be version or a range, e.g. {@code 2.2.1} or {@code [2.2.1,)}
*
* @param mavenVersion the version or {@code null}
*/
public void setMavenVersion( String mavenVersion )
{
this.mavenVersion = mavenVersion;
}
/**
* Only the projects with one of these packagings will be enforced to have the correct prerequisite.
*
* @since 1.4
* @param packagings the list of packagings
*/
public void setPackagings( List<String> packagings )
{
this.packagings = packagings;
}
@Override
| // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
// Path: enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequirePrerequisite.java
import java.util.List;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.model.Prerequisites;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* @author Robert Scholte
* @since 1.3
*/
public class RequirePrerequisite
extends AbstractNonCacheableEnforcerRule
{
/**
* Only the projects with one of these packagings will be enforced to have the correct prerequisite.
*
* @since 1.4
*/
private List<String> packagings;
/**
* Can either be version or a range, e.g. {@code 2.2.1} or {@code [2.2.1,)}
*/
private String mavenVersion;
/**
* Set the mavenVersion Can either be version or a range, e.g. {@code 2.2.1} or {@code [2.2.1,)}
*
* @param mavenVersion the version or {@code null}
*/
public void setMavenVersion( String mavenVersion )
{
this.mavenVersion = mavenVersion;
}
/**
* Only the projects with one of these packagings will be enforced to have the correct prerequisite.
*
* @since 1.4
* @param packagings the list of packagings
*/
public void setPackagings( List<String> packagings )
{
this.packagings = packagings;
}
@Override
| public void execute( EnforcerRuleHelper helper )
|
apache/maven-enforcer | enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireProperty.java | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
| import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.fail;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException; | package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* The Class TestRequireProperty.
*
* @author Paul Gier
*/
public class TestRequireProperty
{
/**
* Test rule.
*
*/
@Test
public void testRule()
{
MockProject project = new MockProject();
project.setProperty( "testProp", "This is a test." ); | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
// Path: enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireProperty.java
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.fail;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* The Class TestRequireProperty.
*
* @author Paul Gier
*/
public class TestRequireProperty
{
/**
* Test rule.
*
*/
@Test
public void testRule()
{
MockProject project = new MockProject();
project.setProperty( "testProp", "This is a test." ); | EnforcerRuleHelper helper = EnforcerTestUtils.getHelper( project ); |
apache/maven-enforcer | enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/utils/EnforcerRuleUtils.java | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
| import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import java.util.List;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.ReportPlugin;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; | package org.apache.maven.plugins.enforcer.utils;
/*
* 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.
*/
/**
* The Class EnforcerRuleUtils.
*
* @author <a href="mailto:[email protected]">Brian Fox</a>
*/
public class EnforcerRuleUtils
{
/** The resolver. */
ArtifactResolver resolver;
/** The local. */
ArtifactRepository local;
/** The remote repositories. */
List<ArtifactRepository> remoteRepositories;
/** The log. */
Log log;
/** The project. */
MavenProject project;
| // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
// Path: enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/utils/EnforcerRuleUtils.java
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import java.util.List;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.ReportPlugin;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
package org.apache.maven.plugins.enforcer.utils;
/*
* 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.
*/
/**
* The Class EnforcerRuleUtils.
*
* @author <a href="mailto:[email protected]">Brian Fox</a>
*/
public class EnforcerRuleUtils
{
/** The resolver. */
ArtifactResolver resolver;
/** The local. */
ArtifactRepository local;
/** The remote repositories. */
List<ArtifactRepository> remoteRepositories;
/** The log. */
Log log;
/** The project. */
MavenProject project;
| private EnforcerRuleHelper helper; |
apache/maven-enforcer | enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/AbstractVersionEnforcer.java | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRule.java
// public interface EnforcerRule
// {
//
// /**
// * This is the interface into the rule. This method should throw an exception
// * containing a reason message if the rule fails the check. The plugin will
// * then decide based on the fail flag if it should stop or just log the
// * message as a warning.
// *
// * @param helper The helper provides access to the log, MavenSession and has
// * helpers to get common components. It is also able to lookup components
// * by class name.
// *
// * @throws EnforcerRuleException the enforcer rule exception
// */
// void execute( @Nonnull EnforcerRuleHelper helper )
// throws EnforcerRuleException;
//
// /**
// * This method tells the enforcer if the rule results may be cached. If the result is true,
// * the results will be remembered for future executions in the same build (ie children). Subsequent
// * iterations of the rule will be queried to see if they are also cacheable. This will allow the rule to be
// * uncached further down the tree if needed.
// *
// * @return <code>true</code> if rule is cacheable
// */
// boolean isCacheable();
//
// /**
// * If the rule is cacheable and the same id is found in the cache, the stored results are passed to this method to
// * allow double checking of the results. Most of the time this can be done by generating unique ids, but sometimes
// * the results of objects returned by the helper need to be queried. You may for example, store certain objects in
// * your rule and then query them later.
// *
// * @param cachedRule the last cached instance of the rule. This is to be used by the rule to
// * potentially determine if the results are still valid (ie if the configuration has been overridden)
// *
// * @return <code>true</code> if the stored results are valid for the same id.
// */
// boolean isResultValid( @Nonnull EnforcerRule cachedRule );
//
// /**
// * If the rule is to be cached, this id is used as part of the key. This can allow rules to take parameters
// * that allow multiple results of the same rule to be cached.
// *
// * @return id to be used by the enforcer to determine uniqueness of cache results. The ids only need to be unique
// * within a given rule implementation as the full key will be [classname]-[id]
// */
// @Nullable
// String getCacheId();
//
// }
| import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.enforcer.rule.api.EnforcerRule;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.plugin.logging.Log;
import org.codehaus.plexus.util.StringUtils; | {
// only singular versions ever have a recommendedVersion
int compareTo = recommendedVersion.compareTo( theVersion );
return ( compareTo <= 0 );
}
}
@Override
public String getCacheId()
{
if ( StringUtils.isNotEmpty( version ) )
{
// return the hashcodes of the parameter that matters
return "" + version.hashCode();
}
else
{
return "0";
}
}
@Override
public boolean isCacheable()
{
// the maven version is not going to change between projects in the same build.
return true;
}
@Override | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRule.java
// public interface EnforcerRule
// {
//
// /**
// * This is the interface into the rule. This method should throw an exception
// * containing a reason message if the rule fails the check. The plugin will
// * then decide based on the fail flag if it should stop or just log the
// * message as a warning.
// *
// * @param helper The helper provides access to the log, MavenSession and has
// * helpers to get common components. It is also able to lookup components
// * by class name.
// *
// * @throws EnforcerRuleException the enforcer rule exception
// */
// void execute( @Nonnull EnforcerRuleHelper helper )
// throws EnforcerRuleException;
//
// /**
// * This method tells the enforcer if the rule results may be cached. If the result is true,
// * the results will be remembered for future executions in the same build (ie children). Subsequent
// * iterations of the rule will be queried to see if they are also cacheable. This will allow the rule to be
// * uncached further down the tree if needed.
// *
// * @return <code>true</code> if rule is cacheable
// */
// boolean isCacheable();
//
// /**
// * If the rule is cacheable and the same id is found in the cache, the stored results are passed to this method to
// * allow double checking of the results. Most of the time this can be done by generating unique ids, but sometimes
// * the results of objects returned by the helper need to be queried. You may for example, store certain objects in
// * your rule and then query them later.
// *
// * @param cachedRule the last cached instance of the rule. This is to be used by the rule to
// * potentially determine if the results are still valid (ie if the configuration has been overridden)
// *
// * @return <code>true</code> if the stored results are valid for the same id.
// */
// boolean isResultValid( @Nonnull EnforcerRule cachedRule );
//
// /**
// * If the rule is to be cached, this id is used as part of the key. This can allow rules to take parameters
// * that allow multiple results of the same rule to be cached.
// *
// * @return id to be used by the enforcer to determine uniqueness of cache results. The ids only need to be unique
// * within a given rule implementation as the full key will be [classname]-[id]
// */
// @Nullable
// String getCacheId();
//
// }
// Path: enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/AbstractVersionEnforcer.java
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.enforcer.rule.api.EnforcerRule;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.plugin.logging.Log;
import org.codehaus.plexus.util.StringUtils;
{
// only singular versions ever have a recommendedVersion
int compareTo = recommendedVersion.compareTo( theVersion );
return ( compareTo <= 0 );
}
}
@Override
public String getCacheId()
{
if ( StringUtils.isNotEmpty( version ) )
{
// return the hashcodes of the parameter that matters
return "" + version.hashCode();
}
else
{
return "0";
}
}
@Override
public boolean isCacheable()
{
// the maven version is not going to change between projects in the same build.
return true;
}
@Override | public boolean isResultValid( EnforcerRule theCachedRule ) |
apache/maven-enforcer | enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireOS.java | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRule.java
// public interface EnforcerRule
// {
//
// /**
// * This is the interface into the rule. This method should throw an exception
// * containing a reason message if the rule fails the check. The plugin will
// * then decide based on the fail flag if it should stop or just log the
// * message as a warning.
// *
// * @param helper The helper provides access to the log, MavenSession and has
// * helpers to get common components. It is also able to lookup components
// * by class name.
// *
// * @throws EnforcerRuleException the enforcer rule exception
// */
// void execute( @Nonnull EnforcerRuleHelper helper )
// throws EnforcerRuleException;
//
// /**
// * This method tells the enforcer if the rule results may be cached. If the result is true,
// * the results will be remembered for future executions in the same build (ie children). Subsequent
// * iterations of the rule will be queried to see if they are also cacheable. This will allow the rule to be
// * uncached further down the tree if needed.
// *
// * @return <code>true</code> if rule is cacheable
// */
// boolean isCacheable();
//
// /**
// * If the rule is cacheable and the same id is found in the cache, the stored results are passed to this method to
// * allow double checking of the results. Most of the time this can be done by generating unique ids, but sometimes
// * the results of objects returned by the helper need to be queried. You may for example, store certain objects in
// * your rule and then query them later.
// *
// * @param cachedRule the last cached instance of the rule. This is to be used by the rule to
// * potentially determine if the results are still valid (ie if the configuration has been overridden)
// *
// * @return <code>true</code> if the stored results are valid for the same id.
// */
// boolean isResultValid( @Nonnull EnforcerRule cachedRule );
//
// /**
// * If the rule is to be cached, this id is used as part of the key. This can allow rules to take parameters
// * that allow multiple results of the same rule to be cached.
// *
// * @return id to be used by the enforcer to determine uniqueness of cache results. The ids only need to be unique
// * within a given rule implementation as the full key will be [classname]-[id]
// */
// @Nullable
// String getCacheId();
//
// }
//
// Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
| import org.codehaus.plexus.util.Os;
import org.codehaus.plexus.util.StringUtils;
import java.util.Iterator;
import org.apache.maven.enforcer.rule.api.EnforcerRule;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.model.Activation;
import org.apache.maven.model.ActivationOS;
import org.apache.maven.model.Profile;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.model.profile.activation.ProfileActivator;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException; | {
// return the hashcodes of all the parameters
StringBuilder b = new StringBuilder();
if ( StringUtils.isNotEmpty( version ) )
{
b.append( version.hashCode() );
}
if ( StringUtils.isNotEmpty( name ) )
{
b.append( name.hashCode() );
}
if ( StringUtils.isNotEmpty( arch ) )
{
b.append( arch.hashCode() );
}
if ( StringUtils.isNotEmpty( family ) )
{
b.append( family.hashCode() );
}
return b.toString();
}
@Override
public boolean isCacheable()
{
// the os is not going to change between projects in the same build.
return true;
}
@Override | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRule.java
// public interface EnforcerRule
// {
//
// /**
// * This is the interface into the rule. This method should throw an exception
// * containing a reason message if the rule fails the check. The plugin will
// * then decide based on the fail flag if it should stop or just log the
// * message as a warning.
// *
// * @param helper The helper provides access to the log, MavenSession and has
// * helpers to get common components. It is also able to lookup components
// * by class name.
// *
// * @throws EnforcerRuleException the enforcer rule exception
// */
// void execute( @Nonnull EnforcerRuleHelper helper )
// throws EnforcerRuleException;
//
// /**
// * This method tells the enforcer if the rule results may be cached. If the result is true,
// * the results will be remembered for future executions in the same build (ie children). Subsequent
// * iterations of the rule will be queried to see if they are also cacheable. This will allow the rule to be
// * uncached further down the tree if needed.
// *
// * @return <code>true</code> if rule is cacheable
// */
// boolean isCacheable();
//
// /**
// * If the rule is cacheable and the same id is found in the cache, the stored results are passed to this method to
// * allow double checking of the results. Most of the time this can be done by generating unique ids, but sometimes
// * the results of objects returned by the helper need to be queried. You may for example, store certain objects in
// * your rule and then query them later.
// *
// * @param cachedRule the last cached instance of the rule. This is to be used by the rule to
// * potentially determine if the results are still valid (ie if the configuration has been overridden)
// *
// * @return <code>true</code> if the stored results are valid for the same id.
// */
// boolean isResultValid( @Nonnull EnforcerRule cachedRule );
//
// /**
// * If the rule is to be cached, this id is used as part of the key. This can allow rules to take parameters
// * that allow multiple results of the same rule to be cached.
// *
// * @return id to be used by the enforcer to determine uniqueness of cache results. The ids only need to be unique
// * within a given rule implementation as the full key will be [classname]-[id]
// */
// @Nullable
// String getCacheId();
//
// }
//
// Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
// Path: enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireOS.java
import org.codehaus.plexus.util.Os;
import org.codehaus.plexus.util.StringUtils;
import java.util.Iterator;
import org.apache.maven.enforcer.rule.api.EnforcerRule;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.model.Activation;
import org.apache.maven.model.ActivationOS;
import org.apache.maven.model.Profile;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.model.profile.activation.ProfileActivator;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
{
// return the hashcodes of all the parameters
StringBuilder b = new StringBuilder();
if ( StringUtils.isNotEmpty( version ) )
{
b.append( version.hashCode() );
}
if ( StringUtils.isNotEmpty( name ) )
{
b.append( name.hashCode() );
}
if ( StringUtils.isNotEmpty( arch ) )
{
b.append( arch.hashCode() );
}
if ( StringUtils.isNotEmpty( family ) )
{
b.append( family.hashCode() );
}
return b.toString();
}
@Override
public boolean isCacheable()
{
// the os is not going to change between projects in the same build.
return true;
}
@Override | public boolean isResultValid( EnforcerRule theCachedRule ) |
apache/maven-enforcer | enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireJavaVendor.java | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
| import java.util.List;
import org.apache.commons.lang3.SystemUtils;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper; | package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* This rule checks that the Java vendor is allowed.
* Rule will fail is it matches any of the excludes or doesn't match any include in case it was set.
*
* @author Tim Sijstermans
* @since 3.0.0
*/
public class RequireJavaVendor extends AbstractNonCacheableEnforcerRule
{
/**
* Java vendors to include. If none is defined, all are included.
*
*/
private List<String> includes;
/**
* Java vendors to exclude.
*/
private List<String> excludes;
@Override | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
// Path: enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireJavaVendor.java
import java.util.List;
import org.apache.commons.lang3.SystemUtils;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* This rule checks that the Java vendor is allowed.
* Rule will fail is it matches any of the excludes or doesn't match any include in case it was set.
*
* @author Tim Sijstermans
* @since 3.0.0
*/
public class RequireJavaVendor extends AbstractNonCacheableEnforcerRule
{
/**
* Java vendors to include. If none is defined, all are included.
*
*/
private List<String> includes;
/**
* Java vendors to exclude.
*/
private List<String> excludes;
@Override | public void execute( EnforcerRuleHelper helper ) throws EnforcerRuleException |
apache/maven-enforcer | enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/AlwaysFail.java | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
| import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper; | package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* Always fail. This rule is useful for testing the Enforcer configuration, or to always fail the build if a particular
* profile is enabled.
* @author Ben Lidgey
*/
public class AlwaysFail
extends AbstractNonCacheableEnforcerRule
{
@Override | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
// Path: enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/AlwaysFail.java
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* Always fail. This rule is useful for testing the Enforcer configuration, or to always fail the build if a particular
* profile is enabled.
* @author Ben Lidgey
*/
public class AlwaysFail
extends AbstractNonCacheableEnforcerRule
{
@Override | public void execute( EnforcerRuleHelper helper ) |
apache/maven-enforcer | enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/BanDistributionManagementTest.java | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
| import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.model.DeploymentRepository;
import org.apache.maven.model.DistributionManagement;
import org.apache.maven.model.Model;
import org.apache.maven.model.Site;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject; | package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* This class is intended to test the {@link BanDistributionManagement} rule.
*
* @author <a href="mailto:[email protected]">Karl Heinz Marbaise</a>
*/
public class BanDistributionManagementTest
{
private MavenProject project;
| // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
// Path: enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/BanDistributionManagementTest.java
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.model.DeploymentRepository;
import org.apache.maven.model.DistributionManagement;
import org.apache.maven.model.Model;
import org.apache.maven.model.Site;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* This class is intended to test the {@link BanDistributionManagement} rule.
*
* @author <a href="mailto:[email protected]">Karl Heinz Marbaise</a>
*/
public class BanDistributionManagementTest
{
private MavenProject project;
| private EnforcerRuleHelper helper; |
apache/maven-enforcer | enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireOS.java | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
| import org.codehaus.plexus.util.Os;
import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.jupiter.api.Assertions.*;
import java.util.Iterator;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.model.profile.activation.OperatingSystemProfileActivator;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugin.logging.SystemStreamLog; | assertTrue( rule.isAllowed() );
rule.setArch( null );
rule.setName( Os.OS_NAME );
assertTrue( rule.isAllowed() );
rule.setName( "somecrazyname" );
assertFalse( rule.isAllowed() );
rule.setName( "!somecrazyname" );
assertTrue( rule.isAllowed() );
rule.setName( null );
rule.setVersion( Os.OS_VERSION );
assertTrue( rule.isAllowed() );
rule.setVersion( "somecrazyversion" );
assertFalse( rule.isAllowed() );
rule.setVersion( "!somecrazyversion" );
assertTrue( rule.isAllowed() );
}
@Test
public void testInvalidFamily()
{
RequireOS rule = new RequireOS();
| // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
// Path: enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireOS.java
import org.codehaus.plexus.util.Os;
import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.jupiter.api.Assertions.*;
import java.util.Iterator;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.model.profile.activation.OperatingSystemProfileActivator;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugin.logging.SystemStreamLog;
assertTrue( rule.isAllowed() );
rule.setArch( null );
rule.setName( Os.OS_NAME );
assertTrue( rule.isAllowed() );
rule.setName( "somecrazyname" );
assertFalse( rule.isAllowed() );
rule.setName( "!somecrazyname" );
assertTrue( rule.isAllowed() );
rule.setName( null );
rule.setVersion( Os.OS_VERSION );
assertTrue( rule.isAllowed() );
rule.setVersion( "somecrazyversion" );
assertFalse( rule.isAllowed() );
rule.setVersion( "!somecrazyversion" );
assertTrue( rule.isAllowed() );
}
@Test
public void testInvalidFamily()
{
RequireOS rule = new RequireOS();
| EnforcerRuleHelper helper = EnforcerTestUtils.getHelper(); |
apache/maven-enforcer | maven-enforcer-plugin/src/test/java/org/apache/maven/plugins/enforcer/MockEnforcerRule.java | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRule.java
// public interface EnforcerRule
// {
//
// /**
// * This is the interface into the rule. This method should throw an exception
// * containing a reason message if the rule fails the check. The plugin will
// * then decide based on the fail flag if it should stop or just log the
// * message as a warning.
// *
// * @param helper The helper provides access to the log, MavenSession and has
// * helpers to get common components. It is also able to lookup components
// * by class name.
// *
// * @throws EnforcerRuleException the enforcer rule exception
// */
// void execute( @Nonnull EnforcerRuleHelper helper )
// throws EnforcerRuleException;
//
// /**
// * This method tells the enforcer if the rule results may be cached. If the result is true,
// * the results will be remembered for future executions in the same build (ie children). Subsequent
// * iterations of the rule will be queried to see if they are also cacheable. This will allow the rule to be
// * uncached further down the tree if needed.
// *
// * @return <code>true</code> if rule is cacheable
// */
// boolean isCacheable();
//
// /**
// * If the rule is cacheable and the same id is found in the cache, the stored results are passed to this method to
// * allow double checking of the results. Most of the time this can be done by generating unique ids, but sometimes
// * the results of objects returned by the helper need to be queried. You may for example, store certain objects in
// * your rule and then query them later.
// *
// * @param cachedRule the last cached instance of the rule. This is to be used by the rule to
// * potentially determine if the results are still valid (ie if the configuration has been overridden)
// *
// * @return <code>true</code> if the stored results are valid for the same id.
// */
// boolean isResultValid( @Nonnull EnforcerRule cachedRule );
//
// /**
// * If the rule is to be cached, this id is used as part of the key. This can allow rules to take parameters
// * that allow multiple results of the same rule to be cached.
// *
// * @return id to be used by the enforcer to determine uniqueness of cache results. The ids only need to be unique
// * within a given rule implementation as the full key will be [classname]-[id]
// */
// @Nullable
// String getCacheId();
//
// }
//
// Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
| import org.apache.maven.enforcer.rule.api.EnforcerRule;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper; | package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* @author <a href="mailto:[email protected]">Brian Fox</a>
*/
public class MockEnforcerRule
implements EnforcerRule
{
public boolean failRule = false;
public String cacheId = "";
public boolean isCacheable = false;
public boolean isResultValid = false;
public boolean executed = false;
public MockEnforcerRule( boolean fail )
{
this.failRule = fail;
}
public MockEnforcerRule( boolean fail, String cacheId, boolean isCacheable, boolean isResultValid )
{
this.failRule = fail;
this.isCacheable = isCacheable;
this.isResultValid = isResultValid;
this.cacheId = cacheId;
}
| // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRule.java
// public interface EnforcerRule
// {
//
// /**
// * This is the interface into the rule. This method should throw an exception
// * containing a reason message if the rule fails the check. The plugin will
// * then decide based on the fail flag if it should stop or just log the
// * message as a warning.
// *
// * @param helper The helper provides access to the log, MavenSession and has
// * helpers to get common components. It is also able to lookup components
// * by class name.
// *
// * @throws EnforcerRuleException the enforcer rule exception
// */
// void execute( @Nonnull EnforcerRuleHelper helper )
// throws EnforcerRuleException;
//
// /**
// * This method tells the enforcer if the rule results may be cached. If the result is true,
// * the results will be remembered for future executions in the same build (ie children). Subsequent
// * iterations of the rule will be queried to see if they are also cacheable. This will allow the rule to be
// * uncached further down the tree if needed.
// *
// * @return <code>true</code> if rule is cacheable
// */
// boolean isCacheable();
//
// /**
// * If the rule is cacheable and the same id is found in the cache, the stored results are passed to this method to
// * allow double checking of the results. Most of the time this can be done by generating unique ids, but sometimes
// * the results of objects returned by the helper need to be queried. You may for example, store certain objects in
// * your rule and then query them later.
// *
// * @param cachedRule the last cached instance of the rule. This is to be used by the rule to
// * potentially determine if the results are still valid (ie if the configuration has been overridden)
// *
// * @return <code>true</code> if the stored results are valid for the same id.
// */
// boolean isResultValid( @Nonnull EnforcerRule cachedRule );
//
// /**
// * If the rule is to be cached, this id is used as part of the key. This can allow rules to take parameters
// * that allow multiple results of the same rule to be cached.
// *
// * @return id to be used by the enforcer to determine uniqueness of cache results. The ids only need to be unique
// * within a given rule implementation as the full key will be [classname]-[id]
// */
// @Nullable
// String getCacheId();
//
// }
//
// Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
// Path: maven-enforcer-plugin/src/test/java/org/apache/maven/plugins/enforcer/MockEnforcerRule.java
import org.apache.maven.enforcer.rule.api.EnforcerRule;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* @author <a href="mailto:[email protected]">Brian Fox</a>
*/
public class MockEnforcerRule
implements EnforcerRule
{
public boolean failRule = false;
public String cacheId = "";
public boolean isCacheable = false;
public boolean isResultValid = false;
public boolean executed = false;
public MockEnforcerRule( boolean fail )
{
this.failRule = fail;
}
public MockEnforcerRule( boolean fail, String cacheId, boolean isCacheable, boolean isResultValid )
{
this.failRule = fail;
this.isCacheable = isCacheable;
this.isResultValid = isResultValid;
this.cacheId = cacheId;
}
| public void execute( EnforcerRuleHelper helper ) |
apache/maven-enforcer | enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/utils/TestNormalizeLineSeparatorReader.java | // Path: enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/utils/NormalizeLineSeparatorReader.java
// public enum LineSeparator
// {
// WINDOWS( "\r\n", null ), UNIX( "\n", '\r' );
//
// private final char[] separatorChars;
//
// private final Character notPrecededByChar;
//
// LineSeparator( String separator, Character notPrecededByChar )
// {
// separatorChars = separator.toCharArray();
// this.notPrecededByChar = notPrecededByChar;
// }
//
// enum MatchResult
// {
// NO_MATCH,
// POTENTIAL_MATCH,
// MATCH;
// }
//
// /**
// * Checks if two given characters match the line separator represented by this object.
// * @param currentCharacter the character to check against
// * @param previousCharacter optional previous character (may be {@code null})
// * @return one of {@link MatchResult}
// */
// public MatchResult matches( char currentCharacter, Character previousCharacter )
// {
// int len = separatorChars.length;
// if ( currentCharacter == separatorChars[len - 1] )
// {
// if ( len > 1 )
// {
// if ( previousCharacter == null || previousCharacter != separatorChars[len - 1] )
// {
// return MatchResult.NO_MATCH;
// }
// }
// if ( notPrecededByChar != null )
// {
// if ( previousCharacter != null && notPrecededByChar == previousCharacter )
// {
// return MatchResult.NO_MATCH;
// }
// }
// return MatchResult.MATCH;
// }
// else if ( len > 1 && currentCharacter == separatorChars[len - 2] )
// {
// return MatchResult.POTENTIAL_MATCH;
// }
// return MatchResult.NO_MATCH;
// }
// };
| import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import org.apache.commons.io.IOUtils;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.apache.maven.plugins.enforcer.utils.NormalizeLineSeparatorReader.LineSeparator;
import org.junit.jupiter.api.Test; | package org.apache.maven.plugins.enforcer.utils;
/*
* 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.
*/
public class TestNormalizeLineSeparatorReader
{
private final static String UNIX_MULTILINE_STRING = "line1\nline2\n\n";
private final static String WINDOWS_MULTILINE_STRING = "line1\r\nline2\r\n\r\n";
@Test
public void testUnixToWindows()
throws IOException
{
try ( Reader reader = | // Path: enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/utils/NormalizeLineSeparatorReader.java
// public enum LineSeparator
// {
// WINDOWS( "\r\n", null ), UNIX( "\n", '\r' );
//
// private final char[] separatorChars;
//
// private final Character notPrecededByChar;
//
// LineSeparator( String separator, Character notPrecededByChar )
// {
// separatorChars = separator.toCharArray();
// this.notPrecededByChar = notPrecededByChar;
// }
//
// enum MatchResult
// {
// NO_MATCH,
// POTENTIAL_MATCH,
// MATCH;
// }
//
// /**
// * Checks if two given characters match the line separator represented by this object.
// * @param currentCharacter the character to check against
// * @param previousCharacter optional previous character (may be {@code null})
// * @return one of {@link MatchResult}
// */
// public MatchResult matches( char currentCharacter, Character previousCharacter )
// {
// int len = separatorChars.length;
// if ( currentCharacter == separatorChars[len - 1] )
// {
// if ( len > 1 )
// {
// if ( previousCharacter == null || previousCharacter != separatorChars[len - 1] )
// {
// return MatchResult.NO_MATCH;
// }
// }
// if ( notPrecededByChar != null )
// {
// if ( previousCharacter != null && notPrecededByChar == previousCharacter )
// {
// return MatchResult.NO_MATCH;
// }
// }
// return MatchResult.MATCH;
// }
// else if ( len > 1 && currentCharacter == separatorChars[len - 2] )
// {
// return MatchResult.POTENTIAL_MATCH;
// }
// return MatchResult.NO_MATCH;
// }
// };
// Path: enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/utils/TestNormalizeLineSeparatorReader.java
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import org.apache.commons.io.IOUtils;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.apache.maven.plugins.enforcer.utils.NormalizeLineSeparatorReader.LineSeparator;
import org.junit.jupiter.api.Test;
package org.apache.maven.plugins.enforcer.utils;
/*
* 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.
*/
public class TestNormalizeLineSeparatorReader
{
private final static String UNIX_MULTILINE_STRING = "line1\nline2\n\n";
private final static String WINDOWS_MULTILINE_STRING = "line1\r\nline2\r\n\r\n";
@Test
public void testUnixToWindows()
throws IOException
{
try ( Reader reader = | new NormalizeLineSeparatorReader( new StringReader( UNIX_MULTILINE_STRING ), LineSeparator.WINDOWS ) ) |
apache/maven-enforcer | enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/ReactorModuleConvergenceTest.java | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
| import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.execution.ProjectDependencyGraph;
import org.apache.maven.model.Dependency;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; | package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* Check reactorModuleConvergence rule.
*
* @author <a href="mailto:[email protected]">Karl Heinz Marbaise</a>
*/
public class ReactorModuleConvergenceTest
{
private MavenSession session;
| // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
// Path: enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/ReactorModuleConvergenceTest.java
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.execution.ProjectDependencyGraph;
import org.apache.maven.model.Dependency;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* Check reactorModuleConvergence rule.
*
* @author <a href="mailto:[email protected]">Karl Heinz Marbaise</a>
*/
public class ReactorModuleConvergenceTest
{
private MavenSession session;
| private EnforcerRuleHelper helper; |
apache/maven-enforcer | enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestMavenVersion.java | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
| import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.execution.MavenSession;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
import org.junit.jupiter.api.Test;
import java.util.Properties;
import static org.junit.jupiter.api.Assertions.fail; | package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* The Class TestMavenVersion.
*
* @author <a href="mailto:[email protected]">Brian Fox</a>
*/
public class TestMavenVersion
{
/**
* Test rule.
*
* @throws EnforcerRuleException the enforcer rule exception
*/
@Test
public void testRule()
throws EnforcerRuleException
{
RequireMavenVersion rule = new RequireMavenVersion();
rule.setVersion( "2.0.5" );
| // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
// Path: enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestMavenVersion.java
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.execution.MavenSession;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
import org.junit.jupiter.api.Test;
import java.util.Properties;
import static org.junit.jupiter.api.Assertions.fail;
package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* The Class TestMavenVersion.
*
* @author <a href="mailto:[email protected]">Brian Fox</a>
*/
public class TestMavenVersion
{
/**
* Test rule.
*
* @throws EnforcerRuleException the enforcer rule exception
*/
@Test
public void testRule()
throws EnforcerRuleException
{
RequireMavenVersion rule = new RequireMavenVersion();
rule.setVersion( "2.0.5" );
| EnforcerRuleHelper helper = EnforcerTestUtils.getHelper(); |
apache/maven-enforcer | enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireJavaVendor.java | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
| import java.util.Collections;
import org.apache.commons.lang3.SystemUtils;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import java.util.Arrays; | package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* The Class TestRequireJavaVendor.
*
* @author Tim Sijstermans
*/
public class TestRequireJavaVendor
{
private static final String NON_MATCHING_VENDOR = "non-matching-vendor";
private RequireJavaVendor underTest;
@BeforeEach
public void prepareTest()
{
underTest = new RequireJavaVendor();
}
@Test
public void matchingInclude()
throws EnforcerRuleException
{
// Set the required vendor to the current system vendor
underTest.setIncludes( Collections.singletonList( SystemUtils.JAVA_VENDOR ) ); | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
// Path: enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireJavaVendor.java
import java.util.Collections;
import org.apache.commons.lang3.SystemUtils;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import java.util.Arrays;
package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* The Class TestRequireJavaVendor.
*
* @author Tim Sijstermans
*/
public class TestRequireJavaVendor
{
private static final String NON_MATCHING_VENDOR = "non-matching-vendor";
private RequireJavaVendor underTest;
@BeforeEach
public void prepareTest()
{
underTest = new RequireJavaVendor();
}
@Test
public void matchingInclude()
throws EnforcerRuleException
{
// Set the required vendor to the current system vendor
underTest.setIncludes( Collections.singletonList( SystemUtils.JAVA_VENDOR ) ); | final EnforcerRuleHelper helper = EnforcerTestUtils.getHelper(); |
apache/maven-enforcer | enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/BannedDependenciesTestSetup.java | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
| import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.plugin.testing.ArtifactStubFactory;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectBuildingRequest; | package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
public class BannedDependenciesTestSetup
{
public BannedDependenciesTestSetup()
throws IOException
{
this.excludes = new ArrayList<>();
this.includes = new ArrayList<>();
ArtifactStubFactory factory = new ArtifactStubFactory();
MockProject project = new MockProject();
project.setArtifacts( factory.getMixedArtifacts() );
project.setDependencyArtifacts( factory.getScopedArtifacts() );
this.helper = EnforcerTestUtils.getHelper( project );
this.rule = newBannedDependenciesRule();
this.rule.setMessage( null );
this.rule.setExcludes( this.excludes );
this.rule.setIncludes( this.includes );
}
private List<String> excludes;
private final List<String> includes;
private final BannedDependencies rule;
| // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
// Path: enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/BannedDependenciesTestSetup.java
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.plugin.testing.ArtifactStubFactory;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectBuildingRequest;
package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
public class BannedDependenciesTestSetup
{
public BannedDependenciesTestSetup()
throws IOException
{
this.excludes = new ArrayList<>();
this.includes = new ArrayList<>();
ArtifactStubFactory factory = new ArtifactStubFactory();
MockProject project = new MockProject();
project.setArtifacts( factory.getMixedArtifacts() );
project.setDependencyArtifacts( factory.getScopedArtifacts() );
this.helper = EnforcerTestUtils.getHelper( project );
this.rule = newBannedDependenciesRule();
this.rule.setMessage( null );
this.rule.setExcludes( this.excludes );
this.rule.setIncludes( this.includes );
}
private List<String> excludes;
private final List<String> includes;
private final BannedDependencies rule;
| private final EnforcerRuleHelper helper; |
apache/maven-enforcer | enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireMavenVersion.java | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
| import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.execution.MavenSession;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; | package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* This rule checks that the Maven version is allowed.
*
* @author <a href="mailto:[email protected]">Brian Fox</a>
*/
public class RequireMavenVersion
extends AbstractVersionEnforcer
{
@Override | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
// Path: enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireMavenVersion.java
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.execution.MavenSession;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* This rule checks that the Maven version is allowed.
*
* @author <a href="mailto:[email protected]">Brian Fox</a>
*/
public class RequireMavenVersion
extends AbstractVersionEnforcer
{
@Override | public void execute( EnforcerRuleHelper helper ) |
apache/maven-enforcer | enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireEnvironmentVariable.java | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
| import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.fail;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException; | package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* Unit test for {@link RequireEnvironmentVariable}}
*
* @author <a href='mailto:marvin[at]marvinformatics[dot]com'>Marvin Froeder</a>
*/
public class TestRequireEnvironmentVariable
{
/**
* Test rule.
*
*/
@Test
public void testRule()
{
MockProject project = new MockProject();
project.setProperty( "testProp", "This is a test." ); | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
// Path: enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireEnvironmentVariable.java
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.fail;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* Unit test for {@link RequireEnvironmentVariable}}
*
* @author <a href='mailto:marvin[at]marvinformatics[dot]com'>Marvin Froeder</a>
*/
public class TestRequireEnvironmentVariable
{
/**
* Test rule.
*
*/
@Test
public void testRule()
{
MockProject project = new MockProject();
project.setProperty( "testProp", "This is a test." ); | EnforcerRuleHelper helper = EnforcerTestUtils.getHelper( project ); |
apache/maven-enforcer | enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/AbstractRequireFiles.java | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRule.java
// public interface EnforcerRule
// {
//
// /**
// * This is the interface into the rule. This method should throw an exception
// * containing a reason message if the rule fails the check. The plugin will
// * then decide based on the fail flag if it should stop or just log the
// * message as a warning.
// *
// * @param helper The helper provides access to the log, MavenSession and has
// * helpers to get common components. It is also able to lookup components
// * by class name.
// *
// * @throws EnforcerRuleException the enforcer rule exception
// */
// void execute( @Nonnull EnforcerRuleHelper helper )
// throws EnforcerRuleException;
//
// /**
// * This method tells the enforcer if the rule results may be cached. If the result is true,
// * the results will be remembered for future executions in the same build (ie children). Subsequent
// * iterations of the rule will be queried to see if they are also cacheable. This will allow the rule to be
// * uncached further down the tree if needed.
// *
// * @return <code>true</code> if rule is cacheable
// */
// boolean isCacheable();
//
// /**
// * If the rule is cacheable and the same id is found in the cache, the stored results are passed to this method to
// * allow double checking of the results. Most of the time this can be done by generating unique ids, but sometimes
// * the results of objects returned by the helper need to be queried. You may for example, store certain objects in
// * your rule and then query them later.
// *
// * @param cachedRule the last cached instance of the rule. This is to be used by the rule to
// * potentially determine if the results are still valid (ie if the configuration has been overridden)
// *
// * @return <code>true</code> if the stored results are valid for the same id.
// */
// boolean isResultValid( @Nonnull EnforcerRule cachedRule );
//
// /**
// * If the rule is to be cached, this id is used as part of the key. This can allow rules to take parameters
// * that allow multiple results of the same rule to be cached.
// *
// * @return id to be used by the enforcer to determine uniqueness of cache results. The ids only need to be unique
// * within a given rule implementation as the full key will be [classname]-[id]
// */
// @Nullable
// String getCacheId();
//
// }
//
// Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
| import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.apache.maven.enforcer.rule.api.EnforcerRule;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper; | }
/**
* Calculates a hash code for the specified array as <code>Arrays.hashCode()</code> would do. Unfortunately, the
* mentioned method is only available for Java 1.5 and later.
*
* @param items The array for which to compute the hash code, may be <code>null</code>.
* @return The hash code for the array.
*/
private static int hashCode( Object[] items )
{
int hash = 0;
if ( items != null )
{
hash = 1;
for ( Object item : items )
{
hash = 31 * hash + ( item == null ? 0 : item.hashCode() );
}
}
return hash;
}
@Override
public boolean isCacheable()
{
return true;
}
@Override | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRule.java
// public interface EnforcerRule
// {
//
// /**
// * This is the interface into the rule. This method should throw an exception
// * containing a reason message if the rule fails the check. The plugin will
// * then decide based on the fail flag if it should stop or just log the
// * message as a warning.
// *
// * @param helper The helper provides access to the log, MavenSession and has
// * helpers to get common components. It is also able to lookup components
// * by class name.
// *
// * @throws EnforcerRuleException the enforcer rule exception
// */
// void execute( @Nonnull EnforcerRuleHelper helper )
// throws EnforcerRuleException;
//
// /**
// * This method tells the enforcer if the rule results may be cached. If the result is true,
// * the results will be remembered for future executions in the same build (ie children). Subsequent
// * iterations of the rule will be queried to see if they are also cacheable. This will allow the rule to be
// * uncached further down the tree if needed.
// *
// * @return <code>true</code> if rule is cacheable
// */
// boolean isCacheable();
//
// /**
// * If the rule is cacheable and the same id is found in the cache, the stored results are passed to this method to
// * allow double checking of the results. Most of the time this can be done by generating unique ids, but sometimes
// * the results of objects returned by the helper need to be queried. You may for example, store certain objects in
// * your rule and then query them later.
// *
// * @param cachedRule the last cached instance of the rule. This is to be used by the rule to
// * potentially determine if the results are still valid (ie if the configuration has been overridden)
// *
// * @return <code>true</code> if the stored results are valid for the same id.
// */
// boolean isResultValid( @Nonnull EnforcerRule cachedRule );
//
// /**
// * If the rule is to be cached, this id is used as part of the key. This can allow rules to take parameters
// * that allow multiple results of the same rule to be cached.
// *
// * @return id to be used by the enforcer to determine uniqueness of cache results. The ids only need to be unique
// * within a given rule implementation as the full key will be [classname]-[id]
// */
// @Nullable
// String getCacheId();
//
// }
//
// Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
// Path: enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/AbstractRequireFiles.java
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.apache.maven.enforcer.rule.api.EnforcerRule;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
}
/**
* Calculates a hash code for the specified array as <code>Arrays.hashCode()</code> would do. Unfortunately, the
* mentioned method is only available for Java 1.5 and later.
*
* @param items The array for which to compute the hash code, may be <code>null</code>.
* @return The hash code for the array.
*/
private static int hashCode( Object[] items )
{
int hash = 0;
if ( items != null )
{
hash = 1;
for ( Object item : items )
{
hash = 31 * hash + ( item == null ? 0 : item.hashCode() );
}
}
return hash;
}
@Override
public boolean isCacheable()
{
return true;
}
@Override | public boolean isResultValid( EnforcerRule cachedRule ) |
apache/maven-enforcer | enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireEnvironmentVariable.java | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRule.java
// public interface EnforcerRule
// {
//
// /**
// * This is the interface into the rule. This method should throw an exception
// * containing a reason message if the rule fails the check. The plugin will
// * then decide based on the fail flag if it should stop or just log the
// * message as a warning.
// *
// * @param helper The helper provides access to the log, MavenSession and has
// * helpers to get common components. It is also able to lookup components
// * by class name.
// *
// * @throws EnforcerRuleException the enforcer rule exception
// */
// void execute( @Nonnull EnforcerRuleHelper helper )
// throws EnforcerRuleException;
//
// /**
// * This method tells the enforcer if the rule results may be cached. If the result is true,
// * the results will be remembered for future executions in the same build (ie children). Subsequent
// * iterations of the rule will be queried to see if they are also cacheable. This will allow the rule to be
// * uncached further down the tree if needed.
// *
// * @return <code>true</code> if rule is cacheable
// */
// boolean isCacheable();
//
// /**
// * If the rule is cacheable and the same id is found in the cache, the stored results are passed to this method to
// * allow double checking of the results. Most of the time this can be done by generating unique ids, but sometimes
// * the results of objects returned by the helper need to be queried. You may for example, store certain objects in
// * your rule and then query them later.
// *
// * @param cachedRule the last cached instance of the rule. This is to be used by the rule to
// * potentially determine if the results are still valid (ie if the configuration has been overridden)
// *
// * @return <code>true</code> if the stored results are valid for the same id.
// */
// boolean isResultValid( @Nonnull EnforcerRule cachedRule );
//
// /**
// * If the rule is to be cached, this id is used as part of the key. This can allow rules to take parameters
// * that allow multiple results of the same rule to be cached.
// *
// * @return id to be used by the enforcer to determine uniqueness of cache results. The ids only need to be unique
// * within a given rule implementation as the full key will be [classname]-[id]
// */
// @Nullable
// String getCacheId();
//
// }
//
// Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
| import org.apache.maven.enforcer.rule.api.EnforcerRule;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper; | package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* This rule checks that certain environment variable is set.
*
* @author <a href='mailto:marvin[at]marvinformatics[dot]com'>Marvin Froeder</a>
*/
public class RequireEnvironmentVariable
extends AbstractPropertyEnforcerRule
{
/**
* Specify the required variable.
*/
private String variableName = null;
/**
* @param variableName the variable name
*
* @see #setVariableName(String)
* @see #getVariableName()
*/
public final void setVariableName( String variableName )
{
this.variableName = variableName;
}
public final String getVariableName()
{
return variableName;
}
@Override | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRule.java
// public interface EnforcerRule
// {
//
// /**
// * This is the interface into the rule. This method should throw an exception
// * containing a reason message if the rule fails the check. The plugin will
// * then decide based on the fail flag if it should stop or just log the
// * message as a warning.
// *
// * @param helper The helper provides access to the log, MavenSession and has
// * helpers to get common components. It is also able to lookup components
// * by class name.
// *
// * @throws EnforcerRuleException the enforcer rule exception
// */
// void execute( @Nonnull EnforcerRuleHelper helper )
// throws EnforcerRuleException;
//
// /**
// * This method tells the enforcer if the rule results may be cached. If the result is true,
// * the results will be remembered for future executions in the same build (ie children). Subsequent
// * iterations of the rule will be queried to see if they are also cacheable. This will allow the rule to be
// * uncached further down the tree if needed.
// *
// * @return <code>true</code> if rule is cacheable
// */
// boolean isCacheable();
//
// /**
// * If the rule is cacheable and the same id is found in the cache, the stored results are passed to this method to
// * allow double checking of the results. Most of the time this can be done by generating unique ids, but sometimes
// * the results of objects returned by the helper need to be queried. You may for example, store certain objects in
// * your rule and then query them later.
// *
// * @param cachedRule the last cached instance of the rule. This is to be used by the rule to
// * potentially determine if the results are still valid (ie if the configuration has been overridden)
// *
// * @return <code>true</code> if the stored results are valid for the same id.
// */
// boolean isResultValid( @Nonnull EnforcerRule cachedRule );
//
// /**
// * If the rule is to be cached, this id is used as part of the key. This can allow rules to take parameters
// * that allow multiple results of the same rule to be cached.
// *
// * @return id to be used by the enforcer to determine uniqueness of cache results. The ids only need to be unique
// * within a given rule implementation as the full key will be [classname]-[id]
// */
// @Nullable
// String getCacheId();
//
// }
//
// Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
// Path: enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireEnvironmentVariable.java
import org.apache.maven.enforcer.rule.api.EnforcerRule;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* This rule checks that certain environment variable is set.
*
* @author <a href='mailto:marvin[at]marvinformatics[dot]com'>Marvin Froeder</a>
*/
public class RequireEnvironmentVariable
extends AbstractPropertyEnforcerRule
{
/**
* Specify the required variable.
*/
private String variableName = null;
/**
* @param variableName the variable name
*
* @see #setVariableName(String)
* @see #getVariableName()
*/
public final void setVariableName( String variableName )
{
this.variableName = variableName;
}
public final String getVariableName()
{
return variableName;
}
@Override | public String resolveValue( EnforcerRuleHelper helper ) |
apache/maven-enforcer | enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireFileChecksum.java | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
| import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper; | package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* Rule to validate a binary file to match the specified checksum.
*
* @author Edward Samson
* @author Lyubomyr Shaydariv
* @see RequireTextFileChecksum
*/
public class RequireFileChecksum
extends AbstractNonCacheableEnforcerRule
{
protected File file;
private String checksum;
private String type;
private String nonexistentFileMessage;
@Override | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
// Path: enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireFileChecksum.java
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* Rule to validate a binary file to match the specified checksum.
*
* @author Edward Samson
* @author Lyubomyr Shaydariv
* @see RequireTextFileChecksum
*/
public class RequireFileChecksum
extends AbstractNonCacheableEnforcerRule
{
protected File file;
private String checksum;
private String type;
private String nonexistentFileMessage;
@Override | public void execute( EnforcerRuleHelper helper ) |
apache/maven-enforcer | enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireSnapshotVersion.java | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
//
// Path: enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/utils/EnforcerRuleUtilsHelper.java
// public class EnforcerRuleUtilsHelper
// {
//
// /**
// * Simpler wrapper to execute and deal with the expected result.
// *
// * @param rule the rule
// * @param helper the helper
// * @param shouldFail the should fail
// */
// public static void execute( EnforcerRule rule, EnforcerRuleHelper helper, boolean shouldFail )
// {
// try
// {
// rule.execute( helper );
// if ( shouldFail )
// {
// fail( "Exception expected." );
// }
// }
// catch ( EnforcerRuleException e )
// {
// if ( !shouldFail )
// {
// fail( "No Exception expected:" + e.getMessage() );
// }
// helper.getLog().debug( e.getMessage() );
// }
// }
// }
| import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.plugin.testing.ArtifactStubFactory;
import org.apache.maven.plugins.enforcer.utils.EnforcerRuleUtilsHelper;
import org.apache.maven.project.MavenProject;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.IOException; | package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* Test class for the RequireSnapshotVersion rule.
*/
public class TestRequireSnapshotVersion
{
private MavenProject project;
| // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
//
// Path: enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/utils/EnforcerRuleUtilsHelper.java
// public class EnforcerRuleUtilsHelper
// {
//
// /**
// * Simpler wrapper to execute and deal with the expected result.
// *
// * @param rule the rule
// * @param helper the helper
// * @param shouldFail the should fail
// */
// public static void execute( EnforcerRule rule, EnforcerRuleHelper helper, boolean shouldFail )
// {
// try
// {
// rule.execute( helper );
// if ( shouldFail )
// {
// fail( "Exception expected." );
// }
// }
// catch ( EnforcerRuleException e )
// {
// if ( !shouldFail )
// {
// fail( "No Exception expected:" + e.getMessage() );
// }
// helper.getLog().debug( e.getMessage() );
// }
// }
// }
// Path: enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireSnapshotVersion.java
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.plugin.testing.ArtifactStubFactory;
import org.apache.maven.plugins.enforcer.utils.EnforcerRuleUtilsHelper;
import org.apache.maven.project.MavenProject;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.IOException;
package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* Test class for the RequireSnapshotVersion rule.
*/
public class TestRequireSnapshotVersion
{
private MavenProject project;
| private EnforcerRuleHelper helper; |
apache/maven-enforcer | enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireSnapshotVersion.java | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
//
// Path: enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/utils/EnforcerRuleUtilsHelper.java
// public class EnforcerRuleUtilsHelper
// {
//
// /**
// * Simpler wrapper to execute and deal with the expected result.
// *
// * @param rule the rule
// * @param helper the helper
// * @param shouldFail the should fail
// */
// public static void execute( EnforcerRule rule, EnforcerRuleHelper helper, boolean shouldFail )
// {
// try
// {
// rule.execute( helper );
// if ( shouldFail )
// {
// fail( "Exception expected." );
// }
// }
// catch ( EnforcerRuleException e )
// {
// if ( !shouldFail )
// {
// fail( "No Exception expected:" + e.getMessage() );
// }
// helper.getLog().debug( e.getMessage() );
// }
// }
// }
| import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.plugin.testing.ArtifactStubFactory;
import org.apache.maven.plugins.enforcer.utils.EnforcerRuleUtilsHelper;
import org.apache.maven.project.MavenProject;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.IOException; | package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* Test class for the RequireSnapshotVersion rule.
*/
public class TestRequireSnapshotVersion
{
private MavenProject project;
private EnforcerRuleHelper helper;
private ArtifactStubFactory factory;
private RequireSnapshotVersion rule;
@BeforeEach
public void before()
{
project = new MockProject();
helper = EnforcerTestUtils.getHelper( project );
factory = new ArtifactStubFactory();
rule = new RequireSnapshotVersion();
}
@Test
public void testRequireSnapshot()
throws IOException
{
project.setArtifact( factory.getReleaseArtifact() ); | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
//
// Path: enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/utils/EnforcerRuleUtilsHelper.java
// public class EnforcerRuleUtilsHelper
// {
//
// /**
// * Simpler wrapper to execute and deal with the expected result.
// *
// * @param rule the rule
// * @param helper the helper
// * @param shouldFail the should fail
// */
// public static void execute( EnforcerRule rule, EnforcerRuleHelper helper, boolean shouldFail )
// {
// try
// {
// rule.execute( helper );
// if ( shouldFail )
// {
// fail( "Exception expected." );
// }
// }
// catch ( EnforcerRuleException e )
// {
// if ( !shouldFail )
// {
// fail( "No Exception expected:" + e.getMessage() );
// }
// helper.getLog().debug( e.getMessage() );
// }
// }
// }
// Path: enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireSnapshotVersion.java
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.plugin.testing.ArtifactStubFactory;
import org.apache.maven.plugins.enforcer.utils.EnforcerRuleUtilsHelper;
import org.apache.maven.project.MavenProject;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.IOException;
package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* Test class for the RequireSnapshotVersion rule.
*/
public class TestRequireSnapshotVersion
{
private MavenProject project;
private EnforcerRuleHelper helper;
private ArtifactStubFactory factory;
private RequireSnapshotVersion rule;
@BeforeEach
public void before()
{
project = new MockProject();
helper = EnforcerTestUtils.getHelper( project );
factory = new ArtifactStubFactory();
rule = new RequireSnapshotVersion();
}
@Test
public void testRequireSnapshot()
throws IOException
{
project.setArtifact( factory.getReleaseArtifact() ); | EnforcerRuleUtilsHelper.execute( rule, helper, true ); |
apache/maven-enforcer | enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/BannedDependencies.java | // Path: enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/utils/ArtifactUtils.java
// public final class ArtifactUtils
// {
// private ArtifactUtils()
// {
// }
//
// public static Set<Artifact> getAllDescendants( DependencyNode node )
// {
// Set<Artifact> children = null;
// if ( node.getChildren() != null )
// {
// children = new HashSet<>();
// for ( DependencyNode depNode : node.getChildren() )
// {
// children.add( depNode.getArtifact() );
// Set<Artifact> subNodes = getAllDescendants( depNode );
// if ( subNodes != null )
// {
// children.addAll( subNodes );
// }
// }
// }
// return children;
// }
//
// /**
// * Checks the set of dependencies against the list of patterns.
// *
// * @param thePatterns the patterns
// * @param dependencies the dependencies
// * @return a set containing artifacts matching one of the patterns or <code>null</code>
// * @throws EnforcerRuleException the enforcer rule exception
// */
// public static Set<Artifact> checkDependencies( Set<Artifact> dependencies, List<String> thePatterns )
// throws EnforcerRuleException
// {
// Set<Artifact> foundMatches = null;
//
// if ( thePatterns != null && thePatterns.size() > 0 )
// {
//
// for ( String pattern : thePatterns )
// {
// String[] subStrings = pattern.split( ":" );
// subStrings = StringUtils.stripAll( subStrings );
// String resultPattern = StringUtils.join( subStrings, ":" );
//
// for ( Artifact artifact : dependencies )
// {
// if ( compareDependency( resultPattern, artifact ) )
// {
// // only create if needed
// if ( foundMatches == null )
// {
// foundMatches = new HashSet<Artifact>();
// }
// foundMatches.add( artifact );
// }
// }
// }
// }
// return foundMatches;
// }
//
// /**
// * Compares the given pattern against the given artifact. The pattern should follow the format
// * <code>groupId:artifactId:version:type:scope:classifier</code>.
// *
// * @param pattern The pattern to compare the artifact with.
// * @param artifact the artifact
// * @return <code>true</code> if the artifact matches one of the patterns
// * @throws EnforcerRuleException the enforcer rule exception
// */
// private static boolean compareDependency( String pattern, Artifact artifact )
// throws EnforcerRuleException
// {
//
// ArtifactMatcher.Pattern am = new Pattern( pattern );
// boolean result;
// try
// {
// result = am.match( artifact );
// }
// catch ( InvalidVersionSpecificationException e )
// {
// throw new EnforcerRuleException( "Invalid Version Range: ", e );
// }
//
// return result;
// }
//
// }
| import java.util.List;
import java.util.Set;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugins.enforcer.utils.ArtifactUtils; | package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* This rule checks that lists of dependencies are not included.
*
* @author <a href="mailto:[email protected]">Brian Fox</a>
*/
public class BannedDependencies
extends AbstractBanDependencies
{
/**
* Specify the banned dependencies. This can be a list of artifacts in the format
* <code>groupId[:artifactId][:version]</code>. Any of the sections can be a wildcard
* by using '*' (ie group:*:1.0) <br>
* The rule will fail if any dependency matches any exclude, unless it also matches
* an include rule.
*
* @see {@link #setExcludes(List)}
* @see {@link #getExcludes()}
*/
private List<String> excludes = null;
/**
* Specify the allowed dependencies. This can be a list of artifacts in the format
* <code>groupId[:artifactId][:version]</code>. Any of the sections can be a wildcard
* by using '*' (ie group:*:1.0) <br>
* Includes override the exclude rules. It is meant to allow wide exclusion rules
* with wildcards and still allow a
* smaller set of includes. <br>
* For example, to ban all xerces except xerces-api -> exclude "xerces", include "xerces:xerces-api"
*
* @see {@link #setIncludes(List)}
* @see {@link #getIncludes()}
*/
private List<String> includes = null;
@Override
protected Set<Artifact> checkDependencies( Set<Artifact> theDependencies, Log log )
throws EnforcerRuleException
{
| // Path: enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/utils/ArtifactUtils.java
// public final class ArtifactUtils
// {
// private ArtifactUtils()
// {
// }
//
// public static Set<Artifact> getAllDescendants( DependencyNode node )
// {
// Set<Artifact> children = null;
// if ( node.getChildren() != null )
// {
// children = new HashSet<>();
// for ( DependencyNode depNode : node.getChildren() )
// {
// children.add( depNode.getArtifact() );
// Set<Artifact> subNodes = getAllDescendants( depNode );
// if ( subNodes != null )
// {
// children.addAll( subNodes );
// }
// }
// }
// return children;
// }
//
// /**
// * Checks the set of dependencies against the list of patterns.
// *
// * @param thePatterns the patterns
// * @param dependencies the dependencies
// * @return a set containing artifacts matching one of the patterns or <code>null</code>
// * @throws EnforcerRuleException the enforcer rule exception
// */
// public static Set<Artifact> checkDependencies( Set<Artifact> dependencies, List<String> thePatterns )
// throws EnforcerRuleException
// {
// Set<Artifact> foundMatches = null;
//
// if ( thePatterns != null && thePatterns.size() > 0 )
// {
//
// for ( String pattern : thePatterns )
// {
// String[] subStrings = pattern.split( ":" );
// subStrings = StringUtils.stripAll( subStrings );
// String resultPattern = StringUtils.join( subStrings, ":" );
//
// for ( Artifact artifact : dependencies )
// {
// if ( compareDependency( resultPattern, artifact ) )
// {
// // only create if needed
// if ( foundMatches == null )
// {
// foundMatches = new HashSet<Artifact>();
// }
// foundMatches.add( artifact );
// }
// }
// }
// }
// return foundMatches;
// }
//
// /**
// * Compares the given pattern against the given artifact. The pattern should follow the format
// * <code>groupId:artifactId:version:type:scope:classifier</code>.
// *
// * @param pattern The pattern to compare the artifact with.
// * @param artifact the artifact
// * @return <code>true</code> if the artifact matches one of the patterns
// * @throws EnforcerRuleException the enforcer rule exception
// */
// private static boolean compareDependency( String pattern, Artifact artifact )
// throws EnforcerRuleException
// {
//
// ArtifactMatcher.Pattern am = new Pattern( pattern );
// boolean result;
// try
// {
// result = am.match( artifact );
// }
// catch ( InvalidVersionSpecificationException e )
// {
// throw new EnforcerRuleException( "Invalid Version Range: ", e );
// }
//
// return result;
// }
//
// }
// Path: enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/BannedDependencies.java
import java.util.List;
import java.util.Set;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugins.enforcer.utils.ArtifactUtils;
package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* This rule checks that lists of dependencies are not included.
*
* @author <a href="mailto:[email protected]">Brian Fox</a>
*/
public class BannedDependencies
extends AbstractBanDependencies
{
/**
* Specify the banned dependencies. This can be a list of artifacts in the format
* <code>groupId[:artifactId][:version]</code>. Any of the sections can be a wildcard
* by using '*' (ie group:*:1.0) <br>
* The rule will fail if any dependency matches any exclude, unless it also matches
* an include rule.
*
* @see {@link #setExcludes(List)}
* @see {@link #getExcludes()}
*/
private List<String> excludes = null;
/**
* Specify the allowed dependencies. This can be a list of artifacts in the format
* <code>groupId[:artifactId][:version]</code>. Any of the sections can be a wildcard
* by using '*' (ie group:*:1.0) <br>
* Includes override the exclude rules. It is meant to allow wide exclusion rules
* with wildcards and still allow a
* smaller set of includes. <br>
* For example, to ban all xerces except xerces-api -> exclude "xerces", include "xerces:xerces-api"
*
* @see {@link #setIncludes(List)}
* @see {@link #getIncludes()}
*/
private List<String> includes = null;
@Override
protected Set<Artifact> checkDependencies( Set<Artifact> theDependencies, Log log )
throws EnforcerRuleException
{
| Set<Artifact> excluded = ArtifactUtils.checkDependencies( theDependencies, excludes ); |
apache/maven-enforcer | enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/RequireActiveProfileTest.java | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
| import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import static org.junit.jupiter.api.Assertions.assertThrows; | package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* Check the profile rule.
*
* @author <a href="mailto:[email protected]">Karl Heinz Marbaise</a>
*/
public class RequireActiveProfileTest
{
private MavenProject project;
| // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
// Path: enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/RequireActiveProfileTest.java
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import static org.junit.jupiter.api.Assertions.assertThrows;
package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* Check the profile rule.
*
* @author <a href="mailto:[email protected]">Karl Heinz Marbaise</a>
*/
public class RequireActiveProfileTest
{
private MavenProject project;
| private EnforcerRuleHelper helper; |
apache/maven-enforcer | enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/utils/ArtifactUtils.java | // Path: enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/utils/ArtifactMatcher.java
// public static class Pattern
// {
// private String pattern;
//
// private String[] parts;
//
// public Pattern( String pattern )
// {
// if ( pattern == null )
// {
// throw new NullPointerException( "pattern" );
// }
//
// this.pattern = pattern;
//
// parts = pattern.split( ":", 7 );
//
// if ( parts.length == 7 )
// {
// throw new IllegalArgumentException( "Pattern contains too many delimiters." );
// }
//
// for ( String part : parts )
// {
// if ( "".equals( part ) )
// {
// throw new IllegalArgumentException( "Pattern or its part is empty." );
// }
// }
// }
//
// public boolean match( Artifact artifact )
// throws InvalidVersionSpecificationException
// {
// if ( artifact == null )
// {
// throw new NullPointerException( "artifact" );
// }
//
// switch ( parts.length )
// {
// case 6:
// String classifier = artifact.getClassifier();
// if ( !matches( parts[5], classifier ) )
// {
// return false;
// }
// case 5:
// String scope = artifact.getScope();
// if ( scope == null || scope.equals( "" ) )
// {
// scope = Artifact.SCOPE_COMPILE;
// }
//
// if ( !matches( parts[4], scope ) )
// {
// return false;
// }
// case 4:
// String type = artifact.getType();
// if ( type == null || type.equals( "" ) )
// {
// type = "jar";
// }
//
// if ( !matches( parts[3], type ) )
// {
// return false;
// }
//
// case 3:
// if ( !matches( parts[2], artifact.getVersion() ) )
// {
// // CHECKSTYLE_OFF: LineLength
// if ( !AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( parts[2] ),
// new DefaultArtifactVersion(
// artifact.getVersion() ) ) )
// // CHECKSTYLE_ON: LineLength
// {
// return false;
// }
// }
//
// case 2:
// if ( !matches( parts[1], artifact.getArtifactId() ) )
// {
// return false;
// }
// case 1:
// return matches( parts[0], artifact.getGroupId() );
// default:
// throw new AssertionError();
// }
// }
//
// private boolean matches( String expression, String input )
// {
// String regex =
// expression.replace( ".", "\\." ).replace( "*", ".*" ).replace( ":", "\\:" ).replace( '?', '.' )
// .replace( "[", "\\[" ).replace( "]", "\\]" ).replace( "(", "\\(" ).replace( ")", "\\)" );
//
// // TODO: Check if this can be done better or prevented earlier.
// if ( input == null )
// {
// input = "";
// }
//
// return java.util.regex.Pattern.matches( regex, input );
// }
//
// @Override
// public String toString()
// {
// return pattern;
// }
// }
| import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.plugins.enforcer.utils.ArtifactMatcher.Pattern;
import org.apache.maven.shared.dependency.graph.DependencyNode; | for ( Artifact artifact : dependencies )
{
if ( compareDependency( resultPattern, artifact ) )
{
// only create if needed
if ( foundMatches == null )
{
foundMatches = new HashSet<Artifact>();
}
foundMatches.add( artifact );
}
}
}
}
return foundMatches;
}
/**
* Compares the given pattern against the given artifact. The pattern should follow the format
* <code>groupId:artifactId:version:type:scope:classifier</code>.
*
* @param pattern The pattern to compare the artifact with.
* @param artifact the artifact
* @return <code>true</code> if the artifact matches one of the patterns
* @throws EnforcerRuleException the enforcer rule exception
*/
private static boolean compareDependency( String pattern, Artifact artifact )
throws EnforcerRuleException
{
| // Path: enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/utils/ArtifactMatcher.java
// public static class Pattern
// {
// private String pattern;
//
// private String[] parts;
//
// public Pattern( String pattern )
// {
// if ( pattern == null )
// {
// throw new NullPointerException( "pattern" );
// }
//
// this.pattern = pattern;
//
// parts = pattern.split( ":", 7 );
//
// if ( parts.length == 7 )
// {
// throw new IllegalArgumentException( "Pattern contains too many delimiters." );
// }
//
// for ( String part : parts )
// {
// if ( "".equals( part ) )
// {
// throw new IllegalArgumentException( "Pattern or its part is empty." );
// }
// }
// }
//
// public boolean match( Artifact artifact )
// throws InvalidVersionSpecificationException
// {
// if ( artifact == null )
// {
// throw new NullPointerException( "artifact" );
// }
//
// switch ( parts.length )
// {
// case 6:
// String classifier = artifact.getClassifier();
// if ( !matches( parts[5], classifier ) )
// {
// return false;
// }
// case 5:
// String scope = artifact.getScope();
// if ( scope == null || scope.equals( "" ) )
// {
// scope = Artifact.SCOPE_COMPILE;
// }
//
// if ( !matches( parts[4], scope ) )
// {
// return false;
// }
// case 4:
// String type = artifact.getType();
// if ( type == null || type.equals( "" ) )
// {
// type = "jar";
// }
//
// if ( !matches( parts[3], type ) )
// {
// return false;
// }
//
// case 3:
// if ( !matches( parts[2], artifact.getVersion() ) )
// {
// // CHECKSTYLE_OFF: LineLength
// if ( !AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( parts[2] ),
// new DefaultArtifactVersion(
// artifact.getVersion() ) ) )
// // CHECKSTYLE_ON: LineLength
// {
// return false;
// }
// }
//
// case 2:
// if ( !matches( parts[1], artifact.getArtifactId() ) )
// {
// return false;
// }
// case 1:
// return matches( parts[0], artifact.getGroupId() );
// default:
// throw new AssertionError();
// }
// }
//
// private boolean matches( String expression, String input )
// {
// String regex =
// expression.replace( ".", "\\." ).replace( "*", ".*" ).replace( ":", "\\:" ).replace( '?', '.' )
// .replace( "[", "\\[" ).replace( "]", "\\]" ).replace( "(", "\\(" ).replace( ")", "\\)" );
//
// // TODO: Check if this can be done better or prevented earlier.
// if ( input == null )
// {
// input = "";
// }
//
// return java.util.regex.Pattern.matches( regex, input );
// }
//
// @Override
// public String toString()
// {
// return pattern;
// }
// }
// Path: enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/utils/ArtifactUtils.java
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.plugins.enforcer.utils.ArtifactMatcher.Pattern;
import org.apache.maven.shared.dependency.graph.DependencyNode;
for ( Artifact artifact : dependencies )
{
if ( compareDependency( resultPattern, artifact ) )
{
// only create if needed
if ( foundMatches == null )
{
foundMatches = new HashSet<Artifact>();
}
foundMatches.add( artifact );
}
}
}
}
return foundMatches;
}
/**
* Compares the given pattern against the given artifact. The pattern should follow the format
* <code>groupId:artifactId:version:type:scope:classifier</code>.
*
* @param pattern The pattern to compare the artifact with.
* @param artifact the artifact
* @return <code>true</code> if the artifact matches one of the patterns
* @throws EnforcerRuleException the enforcer rule exception
*/
private static boolean compareDependency( String pattern, Artifact artifact )
throws EnforcerRuleException
{
| ArtifactMatcher.Pattern am = new Pattern( pattern ); |
apache/maven-enforcer | enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/BanDistributionManagement.java | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
//
// Path: enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/utils/DistributionManagementCheck.java
// public class DistributionManagementCheck
// {
// private DistributionManagement distributionManagement;
//
// public DistributionManagementCheck( MavenProject project )
// {
// this.distributionManagement = project.getOriginalModel().getDistributionManagement();
// }
//
// public void execute( boolean isAllowRepository, boolean isAllowSnapshotRepository, boolean isAllowSite )
// throws EnforcerRuleException
// {
// if ( hasDistributionManagement() )
// {
// if ( !isAllowRepository && hasRepository() )
// {
// throw new EnforcerRuleException( "You have defined a repository in distributionManagement." );
// }
// else if ( !isAllowSnapshotRepository && hasSnapshotRepository() )
// {
// throw new EnforcerRuleException( "You have defined a snapshotRepository in distributionManagement." );
// }
// else if ( !isAllowSite && hasSite() )
// {
// throw new EnforcerRuleException( "You have defined a site in distributionManagement." );
// }
// }
// }
//
// private boolean hasRepository()
// {
// return getDistributionManagement().getRepository() != null;
// }
//
// public DistributionManagement getDistributionManagement()
// {
// return distributionManagement;
// }
//
// public void setDistributionManagement( DistributionManagement distributionManagement )
// {
// this.distributionManagement = distributionManagement;
// }
//
// private boolean hasSnapshotRepository()
// {
// return getDistributionManagement().getSnapshotRepository() != null;
// }
//
// private boolean hasSite()
// {
// return getDistributionManagement().getSite() != null;
// }
//
// private boolean hasDistributionManagement()
// {
// return getDistributionManagement() != null;
// }
// }
| import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugins.enforcer.utils.DistributionManagementCheck;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; | package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* This rule will check if a pom contains a <code>distributionManagement</code> part. This should be by best practice
* only defined once. It could happen that you like to check the parent as well. This can be activated by using the
* <code>ignoreParent</code> which is by default turned off (<code>true</code>) which means not to check the parent.
*
* @author Karl Heinz Marbaise
* @since 1.4
*/
public class BanDistributionManagement
extends AbstractNonCacheableEnforcerRule
{
/**
* Allow using a repository entry in the distributionManagement area.
*/
private boolean allowRepository = false;
/**
* Allow snapshotRepository entry in the distributionManagement area.
*/
private boolean allowSnapshotRepository = false;
/**
* Allow site entry in the distributionManagement area.
*/
private boolean allowSite = false;
@Override | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
//
// Path: enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/utils/DistributionManagementCheck.java
// public class DistributionManagementCheck
// {
// private DistributionManagement distributionManagement;
//
// public DistributionManagementCheck( MavenProject project )
// {
// this.distributionManagement = project.getOriginalModel().getDistributionManagement();
// }
//
// public void execute( boolean isAllowRepository, boolean isAllowSnapshotRepository, boolean isAllowSite )
// throws EnforcerRuleException
// {
// if ( hasDistributionManagement() )
// {
// if ( !isAllowRepository && hasRepository() )
// {
// throw new EnforcerRuleException( "You have defined a repository in distributionManagement." );
// }
// else if ( !isAllowSnapshotRepository && hasSnapshotRepository() )
// {
// throw new EnforcerRuleException( "You have defined a snapshotRepository in distributionManagement." );
// }
// else if ( !isAllowSite && hasSite() )
// {
// throw new EnforcerRuleException( "You have defined a site in distributionManagement." );
// }
// }
// }
//
// private boolean hasRepository()
// {
// return getDistributionManagement().getRepository() != null;
// }
//
// public DistributionManagement getDistributionManagement()
// {
// return distributionManagement;
// }
//
// public void setDistributionManagement( DistributionManagement distributionManagement )
// {
// this.distributionManagement = distributionManagement;
// }
//
// private boolean hasSnapshotRepository()
// {
// return getDistributionManagement().getSnapshotRepository() != null;
// }
//
// private boolean hasSite()
// {
// return getDistributionManagement().getSite() != null;
// }
//
// private boolean hasDistributionManagement()
// {
// return getDistributionManagement() != null;
// }
// }
// Path: enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/BanDistributionManagement.java
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugins.enforcer.utils.DistributionManagementCheck;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* This rule will check if a pom contains a <code>distributionManagement</code> part. This should be by best practice
* only defined once. It could happen that you like to check the parent as well. This can be activated by using the
* <code>ignoreParent</code> which is by default turned off (<code>true</code>) which means not to check the parent.
*
* @author Karl Heinz Marbaise
* @since 1.4
*/
public class BanDistributionManagement
extends AbstractNonCacheableEnforcerRule
{
/**
* Allow using a repository entry in the distributionManagement area.
*/
private boolean allowRepository = false;
/**
* Allow snapshotRepository entry in the distributionManagement area.
*/
private boolean allowSnapshotRepository = false;
/**
* Allow site entry in the distributionManagement area.
*/
private boolean allowSite = false;
@Override | public void execute( EnforcerRuleHelper helper ) |
apache/maven-enforcer | enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/EnforcerTestUtils.java | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
//
// Path: enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/utils/MockEnforcerExpressionEvaluator.java
// public class MockEnforcerExpressionEvaluator
// extends EnforcerExpressionEvaluator
// {
// /**
// * Instantiates a new mock enforcer expression evaluator.
// *
// * @param theContext the context
// */
// public MockEnforcerExpressionEvaluator( MavenSession theContext )
// {
// super( theContext, new MojoExecution( new MojoDescriptor() ) );
// }
//
// @Override
// public Object evaluate( String expr )
// throws ExpressionEvaluationException
// {
// if ( expr != null )
// {
// // just remove the ${ } and return the name as the value
// return expr.replaceAll( "\\$\\{|}", "" );
// }
// else
// {
// return expr;
// }
// }
//
// }
| import static org.mockito.Mockito.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.Arrays;
import java.util.Collections;
import java.util.Properties;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenExecutionResult;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.InputLocation;
import org.apache.maven.model.InputSource;
import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.plugin.PluginParameterExpressionEvaluator;
import org.apache.maven.plugin.logging.SystemStreamLog;
import org.apache.maven.plugins.enforcer.utils.MockEnforcerExpressionEvaluator;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectBuildingRequest;
import org.apache.maven.shared.dependency.graph.DependencyCollectorBuilder;
import org.apache.maven.shared.dependency.graph.internal.DefaultDependencyNode;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.mockito.Mockito; | */
public static EnforcerRuleHelper getHelper( boolean mockExpression )
{
return getHelper( new MockProject(), mockExpression );
}
/**
* Gets the helper.
*
* @param project the project
* @return the helper
*/
public static EnforcerRuleHelper getHelper( MavenProject project )
{
return getHelper( project, false );
}
/**
* Gets the helper.
*
* @param project the project
* @param mockExpression the mock expression
* @return the helper
*/
public static EnforcerRuleHelper getHelper( MavenProject project, boolean mockExpression )
{
MavenSession session = getMavenSession();
ExpressionEvaluator eval;
if ( mockExpression )
{ | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
//
// Path: enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/utils/MockEnforcerExpressionEvaluator.java
// public class MockEnforcerExpressionEvaluator
// extends EnforcerExpressionEvaluator
// {
// /**
// * Instantiates a new mock enforcer expression evaluator.
// *
// * @param theContext the context
// */
// public MockEnforcerExpressionEvaluator( MavenSession theContext )
// {
// super( theContext, new MojoExecution( new MojoDescriptor() ) );
// }
//
// @Override
// public Object evaluate( String expr )
// throws ExpressionEvaluationException
// {
// if ( expr != null )
// {
// // just remove the ${ } and return the name as the value
// return expr.replaceAll( "\\$\\{|}", "" );
// }
// else
// {
// return expr;
// }
// }
//
// }
// Path: enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/EnforcerTestUtils.java
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.Arrays;
import java.util.Collections;
import java.util.Properties;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenExecutionResult;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.InputLocation;
import org.apache.maven.model.InputSource;
import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.plugin.PluginParameterExpressionEvaluator;
import org.apache.maven.plugin.logging.SystemStreamLog;
import org.apache.maven.plugins.enforcer.utils.MockEnforcerExpressionEvaluator;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectBuildingRequest;
import org.apache.maven.shared.dependency.graph.DependencyCollectorBuilder;
import org.apache.maven.shared.dependency.graph.internal.DefaultDependencyNode;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.mockito.Mockito;
*/
public static EnforcerRuleHelper getHelper( boolean mockExpression )
{
return getHelper( new MockProject(), mockExpression );
}
/**
* Gets the helper.
*
* @param project the project
* @return the helper
*/
public static EnforcerRuleHelper getHelper( MavenProject project )
{
return getHelper( project, false );
}
/**
* Gets the helper.
*
* @param project the project
* @param mockExpression the mock expression
* @return the helper
*/
public static EnforcerRuleHelper getHelper( MavenProject project, boolean mockExpression )
{
MavenSession session = getMavenSession();
ExpressionEvaluator eval;
if ( mockExpression )
{ | eval = new MockEnforcerExpressionEvaluator( session ); |
apache/maven-enforcer | enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireJavaVersion.java | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
| import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import org.apache.commons.lang3.SystemUtils;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.plugin.logging.Log;
import org.codehaus.plexus.util.StringUtils; | package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* This rule checks that the Java version is allowed.
*
* @author <a href="mailto:[email protected]">Brian Fox</a>
*/
public class RequireJavaVersion
extends AbstractVersionEnforcer
{
@Override | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
// Path: enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireJavaVersion.java
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import org.apache.commons.lang3.SystemUtils;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.plugin.logging.Log;
import org.codehaus.plexus.util.StringUtils;
package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* This rule checks that the Java version is allowed.
*
* @author <a href="mailto:[email protected]">Brian Fox</a>
*/
public class RequireJavaVersion
extends AbstractVersionEnforcer
{
@Override | public void execute( EnforcerRuleHelper helper ) |
apache/maven-enforcer | enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireTextFileChecksum.java | // Path: enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/utils/NormalizeLineSeparatorReader.java
// public enum LineSeparator
// {
// WINDOWS( "\r\n", null ), UNIX( "\n", '\r' );
//
// private final char[] separatorChars;
//
// private final Character notPrecededByChar;
//
// LineSeparator( String separator, Character notPrecededByChar )
// {
// separatorChars = separator.toCharArray();
// this.notPrecededByChar = notPrecededByChar;
// }
//
// enum MatchResult
// {
// NO_MATCH,
// POTENTIAL_MATCH,
// MATCH;
// }
//
// /**
// * Checks if two given characters match the line separator represented by this object.
// * @param currentCharacter the character to check against
// * @param previousCharacter optional previous character (may be {@code null})
// * @return one of {@link MatchResult}
// */
// public MatchResult matches( char currentCharacter, Character previousCharacter )
// {
// int len = separatorChars.length;
// if ( currentCharacter == separatorChars[len - 1] )
// {
// if ( len > 1 )
// {
// if ( previousCharacter == null || previousCharacter != separatorChars[len - 1] )
// {
// return MatchResult.NO_MATCH;
// }
// }
// if ( notPrecededByChar != null )
// {
// if ( previousCharacter != null && notPrecededByChar == previousCharacter )
// {
// return MatchResult.NO_MATCH;
// }
// }
// return MatchResult.MATCH;
// }
// else if ( len > 1 && currentCharacter == separatorChars[len - 2] )
// {
// return MatchResult.POTENTIAL_MATCH;
// }
// return MatchResult.NO_MATCH;
// }
// };
| import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.plugins.enforcer.utils.NormalizeLineSeparatorReader.LineSeparator;
import org.codehaus.plexus.util.FileUtils;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir; | package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* Test the "RequireTextFileChecksum" rule
*/
public class TestRequireTextFileChecksum
{
private final RequireTextFileChecksum rule = new RequireTextFileChecksum();
@TempDir
public File temporaryFolder;
@Test
public void testFileChecksumMd5NormalizedFromUnixToWindows()
throws IOException, EnforcerRuleException
{
File f = File.createTempFile( "junit", null, temporaryFolder );
FileUtils.fileWrite( f, "line1\nline2\n" );
rule.setFile( f );
rule.setChecksum( "c6242222cf6ccdb15a43e0e5b1a08810" );
rule.setType( "md5" ); | // Path: enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/utils/NormalizeLineSeparatorReader.java
// public enum LineSeparator
// {
// WINDOWS( "\r\n", null ), UNIX( "\n", '\r' );
//
// private final char[] separatorChars;
//
// private final Character notPrecededByChar;
//
// LineSeparator( String separator, Character notPrecededByChar )
// {
// separatorChars = separator.toCharArray();
// this.notPrecededByChar = notPrecededByChar;
// }
//
// enum MatchResult
// {
// NO_MATCH,
// POTENTIAL_MATCH,
// MATCH;
// }
//
// /**
// * Checks if two given characters match the line separator represented by this object.
// * @param currentCharacter the character to check against
// * @param previousCharacter optional previous character (may be {@code null})
// * @return one of {@link MatchResult}
// */
// public MatchResult matches( char currentCharacter, Character previousCharacter )
// {
// int len = separatorChars.length;
// if ( currentCharacter == separatorChars[len - 1] )
// {
// if ( len > 1 )
// {
// if ( previousCharacter == null || previousCharacter != separatorChars[len - 1] )
// {
// return MatchResult.NO_MATCH;
// }
// }
// if ( notPrecededByChar != null )
// {
// if ( previousCharacter != null && notPrecededByChar == previousCharacter )
// {
// return MatchResult.NO_MATCH;
// }
// }
// return MatchResult.MATCH;
// }
// else if ( len > 1 && currentCharacter == separatorChars[len - 2] )
// {
// return MatchResult.POTENTIAL_MATCH;
// }
// return MatchResult.NO_MATCH;
// }
// };
// Path: enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireTextFileChecksum.java
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.plugins.enforcer.utils.NormalizeLineSeparatorReader.LineSeparator;
import org.codehaus.plexus.util.FileUtils;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* Test the "RequireTextFileChecksum" rule
*/
public class TestRequireTextFileChecksum
{
private final RequireTextFileChecksum rule = new RequireTextFileChecksum();
@TempDir
public File temporaryFolder;
@Test
public void testFileChecksumMd5NormalizedFromUnixToWindows()
throws IOException, EnforcerRuleException
{
File f = File.createTempFile( "junit", null, temporaryFolder );
FileUtils.fileWrite( f, "line1\nline2\n" );
rule.setFile( f );
rule.setChecksum( "c6242222cf6ccdb15a43e0e5b1a08810" );
rule.setType( "md5" ); | rule.setNormalizeLineSeparatorTo( LineSeparator.WINDOWS ); |
apache/maven-enforcer | enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/AbstractNonCacheableEnforcerRule.java | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRule.java
// public interface EnforcerRule
// {
//
// /**
// * This is the interface into the rule. This method should throw an exception
// * containing a reason message if the rule fails the check. The plugin will
// * then decide based on the fail flag if it should stop or just log the
// * message as a warning.
// *
// * @param helper The helper provides access to the log, MavenSession and has
// * helpers to get common components. It is also able to lookup components
// * by class name.
// *
// * @throws EnforcerRuleException the enforcer rule exception
// */
// void execute( @Nonnull EnforcerRuleHelper helper )
// throws EnforcerRuleException;
//
// /**
// * This method tells the enforcer if the rule results may be cached. If the result is true,
// * the results will be remembered for future executions in the same build (ie children). Subsequent
// * iterations of the rule will be queried to see if they are also cacheable. This will allow the rule to be
// * uncached further down the tree if needed.
// *
// * @return <code>true</code> if rule is cacheable
// */
// boolean isCacheable();
//
// /**
// * If the rule is cacheable and the same id is found in the cache, the stored results are passed to this method to
// * allow double checking of the results. Most of the time this can be done by generating unique ids, but sometimes
// * the results of objects returned by the helper need to be queried. You may for example, store certain objects in
// * your rule and then query them later.
// *
// * @param cachedRule the last cached instance of the rule. This is to be used by the rule to
// * potentially determine if the results are still valid (ie if the configuration has been overridden)
// *
// * @return <code>true</code> if the stored results are valid for the same id.
// */
// boolean isResultValid( @Nonnull EnforcerRule cachedRule );
//
// /**
// * If the rule is to be cached, this id is used as part of the key. This can allow rules to take parameters
// * that allow multiple results of the same rule to be cached.
// *
// * @return id to be used by the enforcer to determine uniqueness of cache results. The ids only need to be unique
// * within a given rule implementation as the full key will be [classname]-[id]
// */
// @Nullable
// String getCacheId();
//
// }
| import org.apache.maven.enforcer.rule.api.EnforcerRule; | package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* The Class AbstractNonCacheableEnforcerRule. This is to be used by rules
* that don't need caching... it saves implementing a bunch of methods.
*
* @author <a href="mailto:[email protected]">Brian Fox</a>
*/
public abstract class AbstractNonCacheableEnforcerRule
extends AbstractStandardEnforcerRule
{
@Override
public String getCacheId()
{
return "0";
}
@Override
public boolean isCacheable()
{
return false;
}
@Override | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRule.java
// public interface EnforcerRule
// {
//
// /**
// * This is the interface into the rule. This method should throw an exception
// * containing a reason message if the rule fails the check. The plugin will
// * then decide based on the fail flag if it should stop or just log the
// * message as a warning.
// *
// * @param helper The helper provides access to the log, MavenSession and has
// * helpers to get common components. It is also able to lookup components
// * by class name.
// *
// * @throws EnforcerRuleException the enforcer rule exception
// */
// void execute( @Nonnull EnforcerRuleHelper helper )
// throws EnforcerRuleException;
//
// /**
// * This method tells the enforcer if the rule results may be cached. If the result is true,
// * the results will be remembered for future executions in the same build (ie children). Subsequent
// * iterations of the rule will be queried to see if they are also cacheable. This will allow the rule to be
// * uncached further down the tree if needed.
// *
// * @return <code>true</code> if rule is cacheable
// */
// boolean isCacheable();
//
// /**
// * If the rule is cacheable and the same id is found in the cache, the stored results are passed to this method to
// * allow double checking of the results. Most of the time this can be done by generating unique ids, but sometimes
// * the results of objects returned by the helper need to be queried. You may for example, store certain objects in
// * your rule and then query them later.
// *
// * @param cachedRule the last cached instance of the rule. This is to be used by the rule to
// * potentially determine if the results are still valid (ie if the configuration has been overridden)
// *
// * @return <code>true</code> if the stored results are valid for the same id.
// */
// boolean isResultValid( @Nonnull EnforcerRule cachedRule );
//
// /**
// * If the rule is to be cached, this id is used as part of the key. This can allow rules to take parameters
// * that allow multiple results of the same rule to be cached.
// *
// * @return id to be used by the enforcer to determine uniqueness of cache results. The ids only need to be unique
// * within a given rule implementation as the full key will be [classname]-[id]
// */
// @Nullable
// String getCacheId();
//
// }
// Path: enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/AbstractNonCacheableEnforcerRule.java
import org.apache.maven.enforcer.rule.api.EnforcerRule;
package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* The Class AbstractNonCacheableEnforcerRule. This is to be used by rules
* that don't need caching... it saves implementing a bunch of methods.
*
* @author <a href="mailto:[email protected]">Brian Fox</a>
*/
public abstract class AbstractNonCacheableEnforcerRule
extends AbstractStandardEnforcerRule
{
@Override
public String getCacheId()
{
return "0";
}
@Override
public boolean isCacheable()
{
return false;
}
@Override | public boolean isResultValid( EnforcerRule cachedRule ) |
apache/maven-enforcer | enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/EvaluateBeanshell.java | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
| import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.plugin.logging.Log;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
import org.codehaus.plexus.util.StringUtils;
import bsh.EvalError;
import bsh.Interpreter; | package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* Rule for Maven Enforcer using Beanshell to evaluate a conditional expression.
*
* @author hugonnem
*/
public class EvaluateBeanshell
extends AbstractNonCacheableEnforcerRule
{
/** Beanshell interpreter. */
private static final ThreadLocal<Interpreter> INTERPRETER = new ThreadLocal<Interpreter>()
{
@Override
protected Interpreter initialValue()
{
return new Interpreter();
}
};
/** The condition to be evaluated.
*
* @see {@link #setCondition(String)}
* @see {@link #getCondition()}
* */
private String condition;
public final void setCondition( String condition )
{
this.condition = condition;
}
public final String getCondition()
{
return condition;
}
@Override | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
// Path: enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/EvaluateBeanshell.java
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.plugin.logging.Log;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
import org.codehaus.plexus.util.StringUtils;
import bsh.EvalError;
import bsh.Interpreter;
package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* Rule for Maven Enforcer using Beanshell to evaluate a conditional expression.
*
* @author hugonnem
*/
public class EvaluateBeanshell
extends AbstractNonCacheableEnforcerRule
{
/** Beanshell interpreter. */
private static final ThreadLocal<Interpreter> INTERPRETER = new ThreadLocal<Interpreter>()
{
@Override
protected Interpreter initialValue()
{
return new Interpreter();
}
};
/** The condition to be evaluated.
*
* @see {@link #setCondition(String)}
* @see {@link #getCondition()}
* */
private String condition;
public final void setCondition( String condition )
{
this.condition = condition;
}
public final String getCondition()
{
return condition;
}
@Override | public void execute( EnforcerRuleHelper helper ) |
apache/maven-enforcer | enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireSameVersions.java | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
| import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
| package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* @author Robert Scholte
* @since 1.3
*/
public class RequireSameVersions
extends AbstractNonCacheableEnforcerRule
{
private boolean uniqueVersions;
private Set<String> dependencies = new HashSet<>();
private Set<String> plugins = new HashSet<>();
private Set<String> buildPlugins = new HashSet<>();
private Set<String> reportPlugins = new HashSet<>();
@Override
| // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
// Path: enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireSameVersions.java
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* @author Robert Scholte
* @since 1.3
*/
public class RequireSameVersions
extends AbstractNonCacheableEnforcerRule
{
private boolean uniqueVersions;
private Set<String> dependencies = new HashSet<>();
private Set<String> plugins = new HashSet<>();
private Set<String> buildPlugins = new HashSet<>();
private Set<String> reportPlugins = new HashSet<>();
@Override
| public void execute( EnforcerRuleHelper helper )
|
apache/maven-enforcer | enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireJavaVersion.java | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
| import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.apache.commons.lang3.SystemUtils;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; | // test for non-standard versions
assertThat( RequireJavaVersion.normalizeJDKVersion( "1-5-0-11" ) ).isEqualTo( "1.5.0-11" );
assertThat( RequireJavaVersion.normalizeJDKVersion( "1-_5-_0-_11" ) ).isEqualTo( "1.5.0-11" );
assertThat( RequireJavaVersion.normalizeJDKVersion( "1_5_0_11" ) ).isEqualTo( "1.5.0-11" );
assertThat( RequireJavaVersion.normalizeJDKVersion( "1.5.0-07" ) ).isEqualTo( "1.5.0-7" );
assertThat( RequireJavaVersion.normalizeJDKVersion( "1.5.0-b7" ) ).isEqualTo( "1.5.0-7" );
assertThat( RequireJavaVersion.normalizeJDKVersion( "1.5.0-;7" ) ).isEqualTo( "1.5.0-7" );
assertThat( RequireJavaVersion.normalizeJDKVersion( "1.6.0-dp" ) ).isEqualTo( "1.6.0" );
assertThat( RequireJavaVersion.normalizeJDKVersion( "1.6.0-dp2" ) ).isEqualTo( "1.6.0-2" );
assertThat( RequireJavaVersion.normalizeJDKVersion( "1.8.0_73" ) ).isEqualTo( "1.8.0-73" );
assertThat( RequireJavaVersion.normalizeJDKVersion( "9" ) ).isEqualTo( "9" );
assertThat( RequireJavaVersion.normalizeJDKVersion( "17" ) ).isEqualTo( "17" );
}
/**
* Test rule.
*
* @throws EnforcerRuleException the enforcer rule exception
*/
@Test
public void settingsTheJavaVersionAsNormalizedVersionShouldNotFail()
throws EnforcerRuleException
{
String normalizedJDKVersion = RequireJavaVersion.normalizeJDKVersion( SystemUtils.JAVA_VERSION );
RequireJavaVersion rule = new RequireJavaVersion();
rule.setVersion( normalizedJDKVersion );
| // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
// Path: enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireJavaVersion.java
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.apache.commons.lang3.SystemUtils;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
// test for non-standard versions
assertThat( RequireJavaVersion.normalizeJDKVersion( "1-5-0-11" ) ).isEqualTo( "1.5.0-11" );
assertThat( RequireJavaVersion.normalizeJDKVersion( "1-_5-_0-_11" ) ).isEqualTo( "1.5.0-11" );
assertThat( RequireJavaVersion.normalizeJDKVersion( "1_5_0_11" ) ).isEqualTo( "1.5.0-11" );
assertThat( RequireJavaVersion.normalizeJDKVersion( "1.5.0-07" ) ).isEqualTo( "1.5.0-7" );
assertThat( RequireJavaVersion.normalizeJDKVersion( "1.5.0-b7" ) ).isEqualTo( "1.5.0-7" );
assertThat( RequireJavaVersion.normalizeJDKVersion( "1.5.0-;7" ) ).isEqualTo( "1.5.0-7" );
assertThat( RequireJavaVersion.normalizeJDKVersion( "1.6.0-dp" ) ).isEqualTo( "1.6.0" );
assertThat( RequireJavaVersion.normalizeJDKVersion( "1.6.0-dp2" ) ).isEqualTo( "1.6.0-2" );
assertThat( RequireJavaVersion.normalizeJDKVersion( "1.8.0_73" ) ).isEqualTo( "1.8.0-73" );
assertThat( RequireJavaVersion.normalizeJDKVersion( "9" ) ).isEqualTo( "9" );
assertThat( RequireJavaVersion.normalizeJDKVersion( "17" ) ).isEqualTo( "17" );
}
/**
* Test rule.
*
* @throws EnforcerRuleException the enforcer rule exception
*/
@Test
public void settingsTheJavaVersionAsNormalizedVersionShouldNotFail()
throws EnforcerRuleException
{
String normalizedJDKVersion = RequireJavaVersion.normalizeJDKVersion( SystemUtils.JAVA_VERSION );
RequireJavaVersion rule = new RequireJavaVersion();
rule.setVersion( normalizedJDKVersion );
| EnforcerRuleHelper helper = EnforcerTestUtils.getHelper(); |
apache/maven-enforcer | enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/RequirePrerequisiteTest.java | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
| import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.Collections;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.model.Prerequisites;
| package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
public class RequirePrerequisiteTest
{
private MavenProject project;
| // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
// Path: enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/RequirePrerequisiteTest.java
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.Collections;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.model.Prerequisites;
package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
public class RequirePrerequisiteTest
{
private MavenProject project;
| private EnforcerRuleHelper helper;
|
apache/maven-enforcer | enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestEvaluateBeanshell.java | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
| import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CountDownLatch; | package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* The Class TestEvaluateBeanshell.
*
* @author hugonnem
*/
public class TestEvaluateBeanshell
{
private MockProject project;
@BeforeEach
public void setUp()
{
project = new MockProject();
project.setProperty( "env", "\"This is a test.\"" );
}
/**
* Test rule.
*/
@Test
public void testRulePass()
throws Exception
{
EvaluateBeanshell rule = new EvaluateBeanshell();
// this property should not be set
rule.setCondition( "${env} == \"This is a test.\"" );
rule.setMessage( "We have a variable : ${env}" );
| // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
// Path: enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestEvaluateBeanshell.java
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CountDownLatch;
package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* The Class TestEvaluateBeanshell.
*
* @author hugonnem
*/
public class TestEvaluateBeanshell
{
private MockProject project;
@BeforeEach
public void setUp()
{
project = new MockProject();
project.setProperty( "env", "\"This is a test.\"" );
}
/**
* Test rule.
*/
@Test
public void testRulePass()
throws Exception
{
EvaluateBeanshell rule = new EvaluateBeanshell();
// this property should not be set
rule.setCondition( "${env} == \"This is a test.\"" );
rule.setMessage( "We have a variable : ${env}" );
| EnforcerRuleHelper helper = EnforcerTestUtils.getHelper( project ); |
apache/maven-enforcer | enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/utils/EnforcerRuleUtilsHelper.java | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRule.java
// public interface EnforcerRule
// {
//
// /**
// * This is the interface into the rule. This method should throw an exception
// * containing a reason message if the rule fails the check. The plugin will
// * then decide based on the fail flag if it should stop or just log the
// * message as a warning.
// *
// * @param helper The helper provides access to the log, MavenSession and has
// * helpers to get common components. It is also able to lookup components
// * by class name.
// *
// * @throws EnforcerRuleException the enforcer rule exception
// */
// void execute( @Nonnull EnforcerRuleHelper helper )
// throws EnforcerRuleException;
//
// /**
// * This method tells the enforcer if the rule results may be cached. If the result is true,
// * the results will be remembered for future executions in the same build (ie children). Subsequent
// * iterations of the rule will be queried to see if they are also cacheable. This will allow the rule to be
// * uncached further down the tree if needed.
// *
// * @return <code>true</code> if rule is cacheable
// */
// boolean isCacheable();
//
// /**
// * If the rule is cacheable and the same id is found in the cache, the stored results are passed to this method to
// * allow double checking of the results. Most of the time this can be done by generating unique ids, but sometimes
// * the results of objects returned by the helper need to be queried. You may for example, store certain objects in
// * your rule and then query them later.
// *
// * @param cachedRule the last cached instance of the rule. This is to be used by the rule to
// * potentially determine if the results are still valid (ie if the configuration has been overridden)
// *
// * @return <code>true</code> if the stored results are valid for the same id.
// */
// boolean isResultValid( @Nonnull EnforcerRule cachedRule );
//
// /**
// * If the rule is to be cached, this id is used as part of the key. This can allow rules to take parameters
// * that allow multiple results of the same rule to be cached.
// *
// * @return id to be used by the enforcer to determine uniqueness of cache results. The ids only need to be unique
// * within a given rule implementation as the full key will be [classname]-[id]
// */
// @Nullable
// String getCacheId();
//
// }
//
// Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
| import static org.junit.jupiter.api.Assertions.fail;
import org.apache.maven.enforcer.rule.api.EnforcerRule;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper; | package org.apache.maven.plugins.enforcer.utils;
/*
* 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.
*/
/**
* The Class TestEnforcerRuleUtils.
*
* @author <a href="mailto:[email protected]">Brian Fox</a>
*/
public class EnforcerRuleUtilsHelper
{
/**
* Simpler wrapper to execute and deal with the expected result.
*
* @param rule the rule
* @param helper the helper
* @param shouldFail the should fail
*/ | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRule.java
// public interface EnforcerRule
// {
//
// /**
// * This is the interface into the rule. This method should throw an exception
// * containing a reason message if the rule fails the check. The plugin will
// * then decide based on the fail flag if it should stop or just log the
// * message as a warning.
// *
// * @param helper The helper provides access to the log, MavenSession and has
// * helpers to get common components. It is also able to lookup components
// * by class name.
// *
// * @throws EnforcerRuleException the enforcer rule exception
// */
// void execute( @Nonnull EnforcerRuleHelper helper )
// throws EnforcerRuleException;
//
// /**
// * This method tells the enforcer if the rule results may be cached. If the result is true,
// * the results will be remembered for future executions in the same build (ie children). Subsequent
// * iterations of the rule will be queried to see if they are also cacheable. This will allow the rule to be
// * uncached further down the tree if needed.
// *
// * @return <code>true</code> if rule is cacheable
// */
// boolean isCacheable();
//
// /**
// * If the rule is cacheable and the same id is found in the cache, the stored results are passed to this method to
// * allow double checking of the results. Most of the time this can be done by generating unique ids, but sometimes
// * the results of objects returned by the helper need to be queried. You may for example, store certain objects in
// * your rule and then query them later.
// *
// * @param cachedRule the last cached instance of the rule. This is to be used by the rule to
// * potentially determine if the results are still valid (ie if the configuration has been overridden)
// *
// * @return <code>true</code> if the stored results are valid for the same id.
// */
// boolean isResultValid( @Nonnull EnforcerRule cachedRule );
//
// /**
// * If the rule is to be cached, this id is used as part of the key. This can allow rules to take parameters
// * that allow multiple results of the same rule to be cached.
// *
// * @return id to be used by the enforcer to determine uniqueness of cache results. The ids only need to be unique
// * within a given rule implementation as the full key will be [classname]-[id]
// */
// @Nullable
// String getCacheId();
//
// }
//
// Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
// Path: enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/utils/EnforcerRuleUtilsHelper.java
import static org.junit.jupiter.api.Assertions.fail;
import org.apache.maven.enforcer.rule.api.EnforcerRule;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
package org.apache.maven.plugins.enforcer.utils;
/*
* 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.
*/
/**
* The Class TestEnforcerRuleUtils.
*
* @author <a href="mailto:[email protected]">Brian Fox</a>
*/
public class EnforcerRuleUtilsHelper
{
/**
* Simpler wrapper to execute and deal with the expected result.
*
* @param rule the rule
* @param helper the helper
* @param shouldFail the should fail
*/ | public static void execute( EnforcerRule rule, EnforcerRuleHelper helper, boolean shouldFail ) |
apache/maven-enforcer | enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/utils/EnforcerRuleUtilsHelper.java | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRule.java
// public interface EnforcerRule
// {
//
// /**
// * This is the interface into the rule. This method should throw an exception
// * containing a reason message if the rule fails the check. The plugin will
// * then decide based on the fail flag if it should stop or just log the
// * message as a warning.
// *
// * @param helper The helper provides access to the log, MavenSession and has
// * helpers to get common components. It is also able to lookup components
// * by class name.
// *
// * @throws EnforcerRuleException the enforcer rule exception
// */
// void execute( @Nonnull EnforcerRuleHelper helper )
// throws EnforcerRuleException;
//
// /**
// * This method tells the enforcer if the rule results may be cached. If the result is true,
// * the results will be remembered for future executions in the same build (ie children). Subsequent
// * iterations of the rule will be queried to see if they are also cacheable. This will allow the rule to be
// * uncached further down the tree if needed.
// *
// * @return <code>true</code> if rule is cacheable
// */
// boolean isCacheable();
//
// /**
// * If the rule is cacheable and the same id is found in the cache, the stored results are passed to this method to
// * allow double checking of the results. Most of the time this can be done by generating unique ids, but sometimes
// * the results of objects returned by the helper need to be queried. You may for example, store certain objects in
// * your rule and then query them later.
// *
// * @param cachedRule the last cached instance of the rule. This is to be used by the rule to
// * potentially determine if the results are still valid (ie if the configuration has been overridden)
// *
// * @return <code>true</code> if the stored results are valid for the same id.
// */
// boolean isResultValid( @Nonnull EnforcerRule cachedRule );
//
// /**
// * If the rule is to be cached, this id is used as part of the key. This can allow rules to take parameters
// * that allow multiple results of the same rule to be cached.
// *
// * @return id to be used by the enforcer to determine uniqueness of cache results. The ids only need to be unique
// * within a given rule implementation as the full key will be [classname]-[id]
// */
// @Nullable
// String getCacheId();
//
// }
//
// Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
| import static org.junit.jupiter.api.Assertions.fail;
import org.apache.maven.enforcer.rule.api.EnforcerRule;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper; | package org.apache.maven.plugins.enforcer.utils;
/*
* 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.
*/
/**
* The Class TestEnforcerRuleUtils.
*
* @author <a href="mailto:[email protected]">Brian Fox</a>
*/
public class EnforcerRuleUtilsHelper
{
/**
* Simpler wrapper to execute and deal with the expected result.
*
* @param rule the rule
* @param helper the helper
* @param shouldFail the should fail
*/ | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRule.java
// public interface EnforcerRule
// {
//
// /**
// * This is the interface into the rule. This method should throw an exception
// * containing a reason message if the rule fails the check. The plugin will
// * then decide based on the fail flag if it should stop or just log the
// * message as a warning.
// *
// * @param helper The helper provides access to the log, MavenSession and has
// * helpers to get common components. It is also able to lookup components
// * by class name.
// *
// * @throws EnforcerRuleException the enforcer rule exception
// */
// void execute( @Nonnull EnforcerRuleHelper helper )
// throws EnforcerRuleException;
//
// /**
// * This method tells the enforcer if the rule results may be cached. If the result is true,
// * the results will be remembered for future executions in the same build (ie children). Subsequent
// * iterations of the rule will be queried to see if they are also cacheable. This will allow the rule to be
// * uncached further down the tree if needed.
// *
// * @return <code>true</code> if rule is cacheable
// */
// boolean isCacheable();
//
// /**
// * If the rule is cacheable and the same id is found in the cache, the stored results are passed to this method to
// * allow double checking of the results. Most of the time this can be done by generating unique ids, but sometimes
// * the results of objects returned by the helper need to be queried. You may for example, store certain objects in
// * your rule and then query them later.
// *
// * @param cachedRule the last cached instance of the rule. This is to be used by the rule to
// * potentially determine if the results are still valid (ie if the configuration has been overridden)
// *
// * @return <code>true</code> if the stored results are valid for the same id.
// */
// boolean isResultValid( @Nonnull EnforcerRule cachedRule );
//
// /**
// * If the rule is to be cached, this id is used as part of the key. This can allow rules to take parameters
// * that allow multiple results of the same rule to be cached.
// *
// * @return id to be used by the enforcer to determine uniqueness of cache results. The ids only need to be unique
// * within a given rule implementation as the full key will be [classname]-[id]
// */
// @Nullable
// String getCacheId();
//
// }
//
// Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
// Path: enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/utils/EnforcerRuleUtilsHelper.java
import static org.junit.jupiter.api.Assertions.fail;
import org.apache.maven.enforcer.rule.api.EnforcerRule;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
package org.apache.maven.plugins.enforcer.utils;
/*
* 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.
*/
/**
* The Class TestEnforcerRuleUtils.
*
* @author <a href="mailto:[email protected]">Brian Fox</a>
*/
public class EnforcerRuleUtilsHelper
{
/**
* Simpler wrapper to execute and deal with the expected result.
*
* @param rule the rule
* @param helper the helper
* @param shouldFail the should fail
*/ | public static void execute( EnforcerRule rule, EnforcerRuleHelper helper, boolean shouldFail ) |
apache/maven-enforcer | enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireProfileIdsExist.java | // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
| import java.util.ArrayList;
import java.util.List;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
import org.codehaus.plexus.util.StringUtils;
| package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* Ensure that all profiles mentioned on the commandline do exist.
*
* @author Robert Scholte
* @author Gabriel Belingueres
*/
public class RequireProfileIdsExist extends AbstractNonCacheableEnforcerRule
{
@Override
| // Path: enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
// public interface EnforcerRuleHelper
// extends ExpressionEvaluator
// {
//
// /**
// * Gets the log.
// *
// * @return the log
// */
// @Nonnull
// Log getLog ();
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// <T> T getComponent ( Class<T> clazz )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param componentKey the component key
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// @Nonnull
// Object getComponent ( String componentKey )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param role the role
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Object getComponent ( String role, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component.
// *
// * @param clazz the clazz
// * @param roleHint the role hint
// *
// * @return the component
// *
// * @throws ComponentLookupException the component lookup exception
// */
// <T> T getComponent ( Class<T> clazz, String roleHint )
// throws ComponentLookupException;
//
// /**
// * Gets the component map.
// *
// * @param role the role
// *
// * @return the component map
// *
// * @throws ComponentLookupException the component lookup exception
// */
// Map<String, ?> getComponentMap ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the component list.
// *
// * @param role the role
// *
// * @return the component list
// *
// * @throws ComponentLookupException the component lookup exception
// */
// List<?> getComponentList ( String role )
// throws ComponentLookupException;
//
// /**
// * Gets the container.
// *
// * @return the container
// */
// PlexusContainer getContainer();
// }
// Path: enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireProfileIdsExist.java
import java.util.ArrayList;
import java.util.List;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
import org.codehaus.plexus.util.StringUtils;
package org.apache.maven.plugins.enforcer;
/*
* 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.
*/
/**
* Ensure that all profiles mentioned on the commandline do exist.
*
* @author Robert Scholte
* @author Gabriel Belingueres
*/
public class RequireProfileIdsExist extends AbstractNonCacheableEnforcerRule
{
@Override
| public void execute( EnforcerRuleHelper helper )
|
rock88/aLynx-android-port | aLynx/src/com/rock88dev/alynx/ALynxInput.java | // Path: aLynx/src/com/rock88dev/alynx/ALynxSetting.java
// public static class Rect {
// Rect(int x, int y, int w, int h){
// this.x=x;
// this.y=y;
// this.w=w;
// this.h=h;
// }
// Rect(int x, int y){
// this.x=x;
// this.y=y;
// this.w=64;
// this.h=64;
// }
// public int x,y,w,h;
// }
| import com.rock88dev.alynx.ALynxSetting.Rect;
import android.os.Vibrator;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
| /** aLynx - Atari Lynx emulator for Android OS
*
* Copyright (C) 2012
* @author: rock88
*
* e-mail: [email protected]
*
* http://rock88dev.blogspot.com
*
*/
package com.rock88dev.alynx;
public class ALynxInput {
public static Vibrator vibrator;
public static int vibrator_enable = 0;
public static final int ACTION_POINTER_INDEX_MASK = 0xff00;
public static final int ACTION_POINTER_INDEX_SHIFT = 8;
public static int size = 1, pad_no = 1;
private static final int PAD_UP=0,
PAD_DOWN=1,
PAD_LEFT=2,
PAD_RIGHT=3,
PAD_A=4,
PAD_B=5,
PAD_OPT1=6,
PAD_OPT2=7,
PAD_PAUSE=8,
PAD_UP_LEFT=9,
PAD_UP_RIGHT=10,
PAD_DOWN_LEFT=11,
PAD_DOWN_RIGHT=12;
| // Path: aLynx/src/com/rock88dev/alynx/ALynxSetting.java
// public static class Rect {
// Rect(int x, int y, int w, int h){
// this.x=x;
// this.y=y;
// this.w=w;
// this.h=h;
// }
// Rect(int x, int y){
// this.x=x;
// this.y=y;
// this.w=64;
// this.h=64;
// }
// public int x,y,w,h;
// }
// Path: aLynx/src/com/rock88dev/alynx/ALynxInput.java
import com.rock88dev.alynx.ALynxSetting.Rect;
import android.os.Vibrator;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
/** aLynx - Atari Lynx emulator for Android OS
*
* Copyright (C) 2012
* @author: rock88
*
* e-mail: [email protected]
*
* http://rock88dev.blogspot.com
*
*/
package com.rock88dev.alynx;
public class ALynxInput {
public static Vibrator vibrator;
public static int vibrator_enable = 0;
public static final int ACTION_POINTER_INDEX_MASK = 0xff00;
public static final int ACTION_POINTER_INDEX_SHIFT = 8;
public static int size = 1, pad_no = 1;
private static final int PAD_UP=0,
PAD_DOWN=1,
PAD_LEFT=2,
PAD_RIGHT=3,
PAD_A=4,
PAD_B=5,
PAD_OPT1=6,
PAD_OPT2=7,
PAD_PAUSE=8,
PAD_UP_LEFT=9,
PAD_UP_RIGHT=10,
PAD_DOWN_LEFT=11,
PAD_DOWN_RIGHT=12;
| private static Rect[] rect = new Rect[13];
|
rock88/aLynx-android-port | aLynx/src/com/rock88dev/alynx/ALynxEmuSurface_GL.java | // Path: aLynx/src/com/rock88dev/alynx/ALynxSetting.java
// public static class Rect {
// Rect(int x, int y, int w, int h){
// this.x=x;
// this.y=y;
// this.w=w;
// this.h=h;
// }
// Rect(int x, int y){
// this.x=x;
// this.y=y;
// this.w=64;
// this.h=64;
// }
// public int x,y,w,h;
// }
| import java.nio.ByteBuffer;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
import javax.microedition.khronos.opengles.GL11;
import javax.microedition.khronos.opengles.GL11Ext;
import com.rock88dev.alynx.ALynxSetting.Rect;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.PixelFormat;
import android.opengl.GLSurfaceView;
import android.opengl.GLU;
import android.opengl.GLUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
| /** aLynx - Atari Lynx emulator for Android OS
*
* Copyright (C) 2012
* @author: rock88
*
* e-mail: [email protected]
*
* http://rock88dev.blogspot.com
*
*/
package com.rock88dev.alynx;
public class ALynxEmuSurface_GL extends GLSurfaceView implements android.opengl.GLSurfaceView.Renderer {
private Context mContext = null;
private int[] textures = new int[7];
private ALynxSetting set;
static Bitmap ScreenBitmap = null, bitmap = null;
static private ByteBuffer ScreenBuffer;
long tick = 0, fps = 0;
private int pad_no = 1;
private int s_height;
private int powervr = 0;
private float opacity = 1.0f;
private int size = 1;
| // Path: aLynx/src/com/rock88dev/alynx/ALynxSetting.java
// public static class Rect {
// Rect(int x, int y, int w, int h){
// this.x=x;
// this.y=y;
// this.w=w;
// this.h=h;
// }
// Rect(int x, int y){
// this.x=x;
// this.y=y;
// this.w=64;
// this.h=64;
// }
// public int x,y,w,h;
// }
// Path: aLynx/src/com/rock88dev/alynx/ALynxEmuSurface_GL.java
import java.nio.ByteBuffer;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
import javax.microedition.khronos.opengles.GL11;
import javax.microedition.khronos.opengles.GL11Ext;
import com.rock88dev.alynx.ALynxSetting.Rect;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.PixelFormat;
import android.opengl.GLSurfaceView;
import android.opengl.GLU;
import android.opengl.GLUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
/** aLynx - Atari Lynx emulator for Android OS
*
* Copyright (C) 2012
* @author: rock88
*
* e-mail: [email protected]
*
* http://rock88dev.blogspot.com
*
*/
package com.rock88dev.alynx;
public class ALynxEmuSurface_GL extends GLSurfaceView implements android.opengl.GLSurfaceView.Renderer {
private Context mContext = null;
private int[] textures = new int[7];
private ALynxSetting set;
static Bitmap ScreenBitmap = null, bitmap = null;
static private ByteBuffer ScreenBuffer;
long tick = 0, fps = 0;
private int pad_no = 1;
private int s_height;
private int powervr = 0;
private float opacity = 1.0f;
private int size = 1;
| private Rect[] rect = new Rect[6];
|
brunodles/java-validation | src/test/java/com/github/brunodles/javavalidation/matcher/BooleanMatcherTest.java | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
| import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import com.mscharhag.oleaster.runner.OleasterRunner;
import org.junit.runner.RunWith;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.*;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.*; | package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 04/06/16.
*/
@RunWith(OleasterRunner.class)
public class BooleanMatcherTest {
private BooleanMatcher matcher;
private Boolean param; | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
// Path: src/test/java/com/github/brunodles/javavalidation/matcher/BooleanMatcherTest.java
import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import com.mscharhag.oleaster.runner.OleasterRunner;
import org.junit.runner.RunWith;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.*;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.*;
package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 04/06/16.
*/
@RunWith(OleasterRunner.class)
public class BooleanMatcherTest {
private BooleanMatcher matcher;
private Boolean param; | private IntConsumer adder; |
brunodles/java-validation | src/test/java/com/github/brunodles/javavalidation/matcher/BooleanMatcherTest.java | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
| import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import com.mscharhag.oleaster.runner.OleasterRunner;
import org.junit.runner.RunWith;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.*;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.*; | package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 04/06/16.
*/
@RunWith(OleasterRunner.class)
public class BooleanMatcherTest {
private BooleanMatcher matcher;
private Boolean param;
private IntConsumer adder;
{
describe("given a BooleanMatcher", () -> {
beforeEach(() -> {
adder = mock(IntConsumer.class);
matcher = new BooleanMatcher(param, adder);
});
describe("when param is false", () -> {
before(() -> param = false);
describe("when call isTrue", () -> {
beforeEach(() -> matcher.isTrue());
itShouldNotCallAdder();
});
describe("when call isFalse", () -> {
beforeEach(() -> matcher.isFalse()); | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
// Path: src/test/java/com/github/brunodles/javavalidation/matcher/BooleanMatcherTest.java
import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import com.mscharhag.oleaster.runner.OleasterRunner;
import org.junit.runner.RunWith;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.*;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.*;
package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 04/06/16.
*/
@RunWith(OleasterRunner.class)
public class BooleanMatcherTest {
private BooleanMatcher matcher;
private Boolean param;
private IntConsumer adder;
{
describe("given a BooleanMatcher", () -> {
beforeEach(() -> {
adder = mock(IntConsumer.class);
matcher = new BooleanMatcher(param, adder);
});
describe("when param is false", () -> {
before(() -> param = false);
describe("when call isTrue", () -> {
beforeEach(() -> matcher.isTrue());
itShouldNotCallAdder();
});
describe("when call isFalse", () -> {
beforeEach(() -> matcher.isFalse()); | itShouldCallAdderWith("FALSE", Errors.FALSE); |
brunodles/java-validation | src/main/java/com/github/brunodles/javavalidation/matcher/StringMatcher.java | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/Consumer.java
// @FunctionalInterface
// public interface Consumer<T> {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param t the input argument
// */
// void accept(T t);
//
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/matcher/Common.java
// static void _if(BooleanSupplier condition, IntConsumer block, int error) {
// try {
// if (condition.getAsBoolean()) block.accept(error);
// } catch (Exception e) {
// }
// }
| import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.Consumer;
import com.github.brunodles.retrofunctions.IntConsumer;
import static com.github.brunodles.javavalidation.matcher.Common._if; | package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 03/06/16.
*/
public class StringMatcher implements ObjectMatcher<String, StringMatcher>,
EqualsMatcher<String, StringMatcher> {
private String value; | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/Consumer.java
// @FunctionalInterface
// public interface Consumer<T> {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param t the input argument
// */
// void accept(T t);
//
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/matcher/Common.java
// static void _if(BooleanSupplier condition, IntConsumer block, int error) {
// try {
// if (condition.getAsBoolean()) block.accept(error);
// } catch (Exception e) {
// }
// }
// Path: src/main/java/com/github/brunodles/javavalidation/matcher/StringMatcher.java
import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.Consumer;
import com.github.brunodles.retrofunctions.IntConsumer;
import static com.github.brunodles.javavalidation.matcher.Common._if;
package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 03/06/16.
*/
public class StringMatcher implements ObjectMatcher<String, StringMatcher>,
EqualsMatcher<String, StringMatcher> {
private String value; | private IntConsumer adder; |
brunodles/java-validation | src/main/java/com/github/brunodles/javavalidation/matcher/StringMatcher.java | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/Consumer.java
// @FunctionalInterface
// public interface Consumer<T> {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param t the input argument
// */
// void accept(T t);
//
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/matcher/Common.java
// static void _if(BooleanSupplier condition, IntConsumer block, int error) {
// try {
// if (condition.getAsBoolean()) block.accept(error);
// } catch (Exception e) {
// }
// }
| import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.Consumer;
import com.github.brunodles.retrofunctions.IntConsumer;
import static com.github.brunodles.javavalidation.matcher.Common._if; | package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 03/06/16.
*/
public class StringMatcher implements ObjectMatcher<String, StringMatcher>,
EqualsMatcher<String, StringMatcher> {
private String value;
private IntConsumer adder;
StringMatcher(String value, IntConsumer adder) {
this.value = value;
this.adder = adder;
}
/**
* Check if the reference String is empty
*
* @return the current object, to be used as a builder
*/
public StringMatcher isEmpty() { | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/Consumer.java
// @FunctionalInterface
// public interface Consumer<T> {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param t the input argument
// */
// void accept(T t);
//
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/matcher/Common.java
// static void _if(BooleanSupplier condition, IntConsumer block, int error) {
// try {
// if (condition.getAsBoolean()) block.accept(error);
// } catch (Exception e) {
// }
// }
// Path: src/main/java/com/github/brunodles/javavalidation/matcher/StringMatcher.java
import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.Consumer;
import com.github.brunodles.retrofunctions.IntConsumer;
import static com.github.brunodles.javavalidation.matcher.Common._if;
package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 03/06/16.
*/
public class StringMatcher implements ObjectMatcher<String, StringMatcher>,
EqualsMatcher<String, StringMatcher> {
private String value;
private IntConsumer adder;
StringMatcher(String value, IntConsumer adder) {
this.value = value;
this.adder = adder;
}
/**
* Check if the reference String is empty
*
* @return the current object, to be used as a builder
*/
public StringMatcher isEmpty() { | _if(() -> value.isEmpty(), adder, Errors.EMPTY); |
brunodles/java-validation | src/main/java/com/github/brunodles/javavalidation/matcher/StringMatcher.java | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/Consumer.java
// @FunctionalInterface
// public interface Consumer<T> {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param t the input argument
// */
// void accept(T t);
//
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/matcher/Common.java
// static void _if(BooleanSupplier condition, IntConsumer block, int error) {
// try {
// if (condition.getAsBoolean()) block.accept(error);
// } catch (Exception e) {
// }
// }
| import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.Consumer;
import com.github.brunodles.retrofunctions.IntConsumer;
import static com.github.brunodles.javavalidation.matcher.Common._if; | package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 03/06/16.
*/
public class StringMatcher implements ObjectMatcher<String, StringMatcher>,
EqualsMatcher<String, StringMatcher> {
private String value;
private IntConsumer adder;
StringMatcher(String value, IntConsumer adder) {
this.value = value;
this.adder = adder;
}
/**
* Check if the reference String is empty
*
* @return the current object, to be used as a builder
*/
public StringMatcher isEmpty() { | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/Consumer.java
// @FunctionalInterface
// public interface Consumer<T> {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param t the input argument
// */
// void accept(T t);
//
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/matcher/Common.java
// static void _if(BooleanSupplier condition, IntConsumer block, int error) {
// try {
// if (condition.getAsBoolean()) block.accept(error);
// } catch (Exception e) {
// }
// }
// Path: src/main/java/com/github/brunodles/javavalidation/matcher/StringMatcher.java
import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.Consumer;
import com.github.brunodles.retrofunctions.IntConsumer;
import static com.github.brunodles.javavalidation.matcher.Common._if;
package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 03/06/16.
*/
public class StringMatcher implements ObjectMatcher<String, StringMatcher>,
EqualsMatcher<String, StringMatcher> {
private String value;
private IntConsumer adder;
StringMatcher(String value, IntConsumer adder) {
this.value = value;
this.adder = adder;
}
/**
* Check if the reference String is empty
*
* @return the current object, to be used as a builder
*/
public StringMatcher isEmpty() { | _if(() -> value.isEmpty(), adder, Errors.EMPTY); |
brunodles/java-validation | src/main/java/com/github/brunodles/javavalidation/matcher/StringMatcher.java | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/Consumer.java
// @FunctionalInterface
// public interface Consumer<T> {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param t the input argument
// */
// void accept(T t);
//
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/matcher/Common.java
// static void _if(BooleanSupplier condition, IntConsumer block, int error) {
// try {
// if (condition.getAsBoolean()) block.accept(error);
// } catch (Exception e) {
// }
// }
| import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.Consumer;
import com.github.brunodles.retrofunctions.IntConsumer;
import static com.github.brunodles.javavalidation.matcher.Common._if; | package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 03/06/16.
*/
public class StringMatcher implements ObjectMatcher<String, StringMatcher>,
EqualsMatcher<String, StringMatcher> {
private String value;
private IntConsumer adder;
StringMatcher(String value, IntConsumer adder) {
this.value = value;
this.adder = adder;
}
/**
* Check if the reference String is empty
*
* @return the current object, to be used as a builder
*/
public StringMatcher isEmpty() {
_if(() -> value.isEmpty(), adder, Errors.EMPTY);
return this;
}
/**
* Check if the reference String is null
*
* @return the current object, to be used as a builder
*/
@Override
public StringMatcher isNull() {
_if(() -> value == null, adder, Errors.NULL);
return this;
}
/**
* Check if the length of the reference String is matching
*
* @param matcher a {@link IntegerMatcher} will passed as parameter to the Consumer
* @return the current object, to be used as a builder
*/ | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/Consumer.java
// @FunctionalInterface
// public interface Consumer<T> {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param t the input argument
// */
// void accept(T t);
//
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/matcher/Common.java
// static void _if(BooleanSupplier condition, IntConsumer block, int error) {
// try {
// if (condition.getAsBoolean()) block.accept(error);
// } catch (Exception e) {
// }
// }
// Path: src/main/java/com/github/brunodles/javavalidation/matcher/StringMatcher.java
import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.Consumer;
import com.github.brunodles.retrofunctions.IntConsumer;
import static com.github.brunodles.javavalidation.matcher.Common._if;
package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 03/06/16.
*/
public class StringMatcher implements ObjectMatcher<String, StringMatcher>,
EqualsMatcher<String, StringMatcher> {
private String value;
private IntConsumer adder;
StringMatcher(String value, IntConsumer adder) {
this.value = value;
this.adder = adder;
}
/**
* Check if the reference String is empty
*
* @return the current object, to be used as a builder
*/
public StringMatcher isEmpty() {
_if(() -> value.isEmpty(), adder, Errors.EMPTY);
return this;
}
/**
* Check if the reference String is null
*
* @return the current object, to be used as a builder
*/
@Override
public StringMatcher isNull() {
_if(() -> value == null, adder, Errors.NULL);
return this;
}
/**
* Check if the length of the reference String is matching
*
* @param matcher a {@link IntegerMatcher} will passed as parameter to the Consumer
* @return the current object, to be used as a builder
*/ | public StringMatcher length(Consumer<IntegerMatcher> matcher) { |
brunodles/java-validation | src/test/java/com/github/brunodles/javavalidation/matcher/StringMatcherTest.java | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
| import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import com.mscharhag.oleaster.runner.OleasterRunner;
import org.junit.runner.RunWith;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.*;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.*; | package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 04/06/16.
*/
@RunWith(OleasterRunner.class)
public class StringMatcherTest {
| // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
// Path: src/test/java/com/github/brunodles/javavalidation/matcher/StringMatcherTest.java
import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import com.mscharhag.oleaster.runner.OleasterRunner;
import org.junit.runner.RunWith;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.*;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.*;
package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 04/06/16.
*/
@RunWith(OleasterRunner.class)
public class StringMatcherTest {
| private IntConsumer adder; |
brunodles/java-validation | src/test/java/com/github/brunodles/javavalidation/matcher/StringMatcherTest.java | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
| import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import com.mscharhag.oleaster.runner.OleasterRunner;
import org.junit.runner.RunWith;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.*;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.*; | package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 04/06/16.
*/
@RunWith(OleasterRunner.class)
public class StringMatcherTest {
private IntConsumer adder;
private StringMatcher matcher;
private String param;
{
describe("Given a StringMatcher", () -> {
beforeEach(() -> {
adder = mock(IntConsumer.class);
matcher = new StringMatcher(param, adder);
});
describe("when param is null", () -> {
before(() -> param = null);
describe("when call isEmpty", () -> {
beforeEach(() -> matcher.isEmpty());
itShouldNotCallAdder();
});
describe("when call isNull", () -> {
beforeEach(() -> matcher.isNull()); | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
// Path: src/test/java/com/github/brunodles/javavalidation/matcher/StringMatcherTest.java
import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import com.mscharhag.oleaster.runner.OleasterRunner;
import org.junit.runner.RunWith;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.*;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.*;
package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 04/06/16.
*/
@RunWith(OleasterRunner.class)
public class StringMatcherTest {
private IntConsumer adder;
private StringMatcher matcher;
private String param;
{
describe("Given a StringMatcher", () -> {
beforeEach(() -> {
adder = mock(IntConsumer.class);
matcher = new StringMatcher(param, adder);
});
describe("when param is null", () -> {
before(() -> param = null);
describe("when call isEmpty", () -> {
beforeEach(() -> matcher.isEmpty());
itShouldNotCallAdder();
});
describe("when call isNull", () -> {
beforeEach(() -> matcher.isNull()); | itShouldCallAdderWith("NULL", Errors.NULL); |
brunodles/java-validation | src/main/java/com/github/brunodles/javavalidation/matcher/NumberMatcherImpl.java | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/matcher/Common.java
// static void _if(BooleanSupplier condition, IntConsumer block, int error) {
// try {
// if (condition.getAsBoolean()) block.accept(error);
// } catch (Exception e) {
// }
// }
| import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import static com.github.brunodles.javavalidation.matcher.Common._if; | package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 03/06/16.
*/
class NumberMatcherImpl<T extends Number & Comparable,
SubClass extends NumberMatcherImpl>
implements NumberMatcher<T, SubClass>, ObjectMatcher<T, SubClass> {
private T value; | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/matcher/Common.java
// static void _if(BooleanSupplier condition, IntConsumer block, int error) {
// try {
// if (condition.getAsBoolean()) block.accept(error);
// } catch (Exception e) {
// }
// }
// Path: src/main/java/com/github/brunodles/javavalidation/matcher/NumberMatcherImpl.java
import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import static com.github.brunodles.javavalidation.matcher.Common._if;
package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 03/06/16.
*/
class NumberMatcherImpl<T extends Number & Comparable,
SubClass extends NumberMatcherImpl>
implements NumberMatcher<T, SubClass>, ObjectMatcher<T, SubClass> {
private T value; | private IntConsumer adder; |
brunodles/java-validation | src/main/java/com/github/brunodles/javavalidation/matcher/NumberMatcherImpl.java | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/matcher/Common.java
// static void _if(BooleanSupplier condition, IntConsumer block, int error) {
// try {
// if (condition.getAsBoolean()) block.accept(error);
// } catch (Exception e) {
// }
// }
| import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import static com.github.brunodles.javavalidation.matcher.Common._if; | package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 03/06/16.
*/
class NumberMatcherImpl<T extends Number & Comparable,
SubClass extends NumberMatcherImpl>
implements NumberMatcher<T, SubClass>, ObjectMatcher<T, SubClass> {
private T value;
private IntConsumer adder;
public NumberMatcherImpl(T value, IntConsumer adder) {
this.value = value;
this.adder = adder;
}
@Override
public SubClass isEqualsTo(T expected) { | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/matcher/Common.java
// static void _if(BooleanSupplier condition, IntConsumer block, int error) {
// try {
// if (condition.getAsBoolean()) block.accept(error);
// } catch (Exception e) {
// }
// }
// Path: src/main/java/com/github/brunodles/javavalidation/matcher/NumberMatcherImpl.java
import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import static com.github.brunodles.javavalidation.matcher.Common._if;
package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 03/06/16.
*/
class NumberMatcherImpl<T extends Number & Comparable,
SubClass extends NumberMatcherImpl>
implements NumberMatcher<T, SubClass>, ObjectMatcher<T, SubClass> {
private T value;
private IntConsumer adder;
public NumberMatcherImpl(T value, IntConsumer adder) {
this.value = value;
this.adder = adder;
}
@Override
public SubClass isEqualsTo(T expected) { | _if(() -> value.equals(expected), adder, Errors.EQUAL); |
brunodles/java-validation | src/main/java/com/github/brunodles/javavalidation/matcher/NumberMatcherImpl.java | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/matcher/Common.java
// static void _if(BooleanSupplier condition, IntConsumer block, int error) {
// try {
// if (condition.getAsBoolean()) block.accept(error);
// } catch (Exception e) {
// }
// }
| import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import static com.github.brunodles.javavalidation.matcher.Common._if; | package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 03/06/16.
*/
class NumberMatcherImpl<T extends Number & Comparable,
SubClass extends NumberMatcherImpl>
implements NumberMatcher<T, SubClass>, ObjectMatcher<T, SubClass> {
private T value;
private IntConsumer adder;
public NumberMatcherImpl(T value, IntConsumer adder) {
this.value = value;
this.adder = adder;
}
@Override
public SubClass isEqualsTo(T expected) { | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/matcher/Common.java
// static void _if(BooleanSupplier condition, IntConsumer block, int error) {
// try {
// if (condition.getAsBoolean()) block.accept(error);
// } catch (Exception e) {
// }
// }
// Path: src/main/java/com/github/brunodles/javavalidation/matcher/NumberMatcherImpl.java
import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import static com.github.brunodles.javavalidation.matcher.Common._if;
package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 03/06/16.
*/
class NumberMatcherImpl<T extends Number & Comparable,
SubClass extends NumberMatcherImpl>
implements NumberMatcher<T, SubClass>, ObjectMatcher<T, SubClass> {
private T value;
private IntConsumer adder;
public NumberMatcherImpl(T value, IntConsumer adder) {
this.value = value;
this.adder = adder;
}
@Override
public SubClass isEqualsTo(T expected) { | _if(() -> value.equals(expected), adder, Errors.EQUAL); |
brunodles/java-validation | src/test/java/com/github/brunodles/javavalidation/matcher/ObjectMatcherTest.java | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
| import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import com.mscharhag.oleaster.runner.OleasterRunner;
import org.junit.runner.RunWith;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.*;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.*; | package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 04/06/16.
*/
@RunWith(OleasterRunner.class)
public class ObjectMatcherTest {
private ObjectMatcherImpl<SampleClass> matcher;
| // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
// Path: src/test/java/com/github/brunodles/javavalidation/matcher/ObjectMatcherTest.java
import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import com.mscharhag.oleaster.runner.OleasterRunner;
import org.junit.runner.RunWith;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.*;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.*;
package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 04/06/16.
*/
@RunWith(OleasterRunner.class)
public class ObjectMatcherTest {
private ObjectMatcherImpl<SampleClass> matcher;
| private IntConsumer adder; |
brunodles/java-validation | src/test/java/com/github/brunodles/javavalidation/matcher/ObjectMatcherTest.java | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
| import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import com.mscharhag.oleaster.runner.OleasterRunner;
import org.junit.runner.RunWith;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.*;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.*; | package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 04/06/16.
*/
@RunWith(OleasterRunner.class)
public class ObjectMatcherTest {
private ObjectMatcherImpl<SampleClass> matcher;
private IntConsumer adder;
private SampleClass param;
{
describe("Given a ObjectRunner", () -> {
beforeEach(() -> {
adder = mock(IntConsumer.class);
matcher = new ObjectMatcherImpl<SampleClass>(param, adder);
});
describe("when param is null", () -> {
before(() -> param = null);
describe("when call isNull", () -> {
beforeEach(() -> matcher.isNull()); | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
// Path: src/test/java/com/github/brunodles/javavalidation/matcher/ObjectMatcherTest.java
import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import com.mscharhag.oleaster.runner.OleasterRunner;
import org.junit.runner.RunWith;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.*;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.*;
package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 04/06/16.
*/
@RunWith(OleasterRunner.class)
public class ObjectMatcherTest {
private ObjectMatcherImpl<SampleClass> matcher;
private IntConsumer adder;
private SampleClass param;
{
describe("Given a ObjectRunner", () -> {
beforeEach(() -> {
adder = mock(IntConsumer.class);
matcher = new ObjectMatcherImpl<SampleClass>(param, adder);
});
describe("when param is null", () -> {
before(() -> param = null);
describe("when call isNull", () -> {
beforeEach(() -> matcher.isNull()); | itShouldCallAdderWith("NULL", Errors.NULL); |
brunodles/java-validation | src/test/java/com/github/brunodles/javavalidation/matcher/IntegerMatcherTest.java | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
| import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import com.mscharhag.oleaster.runner.OleasterRunner;
import org.junit.runner.RunWith;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.before;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.describe;
import static org.mockito.Mockito.mock; | package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 04/06/16.
*/
@RunWith(OleasterRunner.class)
public class IntegerMatcherTest extends NumberMatcherTestBase<Integer, IntegerMatcher> {
{
describe("Given a IntegerMatcher for 7", () -> {
before(() -> { | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
// Path: src/test/java/com/github/brunodles/javavalidation/matcher/IntegerMatcherTest.java
import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import com.mscharhag.oleaster.runner.OleasterRunner;
import org.junit.runner.RunWith;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.before;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.describe;
import static org.mockito.Mockito.mock;
package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 04/06/16.
*/
@RunWith(OleasterRunner.class)
public class IntegerMatcherTest extends NumberMatcherTestBase<Integer, IntegerMatcher> {
{
describe("Given a IntegerMatcher for 7", () -> {
before(() -> { | adder = mock(IntConsumer.class); |
brunodles/java-validation | src/test/java/com/github/brunodles/javavalidation/matcher/IntegerMatcherTest.java | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
| import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import com.mscharhag.oleaster.runner.OleasterRunner;
import org.junit.runner.RunWith;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.before;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.describe;
import static org.mockito.Mockito.mock; | package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 04/06/16.
*/
@RunWith(OleasterRunner.class)
public class IntegerMatcherTest extends NumberMatcherTestBase<Integer, IntegerMatcher> {
{
describe("Given a IntegerMatcher for 7", () -> {
before(() -> {
adder = mock(IntConsumer.class);
matcher = new IntegerMatcher(7, adder);
});
describe("when call isBetween", () -> {
when_isBetween(1, 7, this::itShouldNotCallAdder);
when_isBetween(7, 10, this::itShouldNotCallAdder); | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
// Path: src/test/java/com/github/brunodles/javavalidation/matcher/IntegerMatcherTest.java
import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import com.mscharhag.oleaster.runner.OleasterRunner;
import org.junit.runner.RunWith;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.before;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.describe;
import static org.mockito.Mockito.mock;
package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 04/06/16.
*/
@RunWith(OleasterRunner.class)
public class IntegerMatcherTest extends NumberMatcherTestBase<Integer, IntegerMatcher> {
{
describe("Given a IntegerMatcher for 7", () -> {
before(() -> {
adder = mock(IntConsumer.class);
matcher = new IntegerMatcher(7, adder);
});
describe("when call isBetween", () -> {
when_isBetween(1, 7, this::itShouldNotCallAdder);
when_isBetween(7, 10, this::itShouldNotCallAdder); | when_isBetween(5, 9, () -> itShouldCallAdderWith("BETWEEN", Errors.BETWEEN)); |
brunodles/java-validation | src/test/java/com/github/brunodles/javavalidation/matcher/NumberMatcherTestBase.java | // Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
| import com.github.brunodles.retrofunctions.IntConsumer;
import com.mscharhag.oleaster.runner.Invokable;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.*;
import static org.mockito.Mockito.*; | package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 03/06/16.
*/
public abstract class NumberMatcherTestBase<T extends Number, Y extends NumberMatcher<T, ?>> {
protected Y matcher; | // Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
// Path: src/test/java/com/github/brunodles/javavalidation/matcher/NumberMatcherTestBase.java
import com.github.brunodles.retrofunctions.IntConsumer;
import com.mscharhag.oleaster.runner.Invokable;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.*;
import static org.mockito.Mockito.*;
package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 03/06/16.
*/
public abstract class NumberMatcherTestBase<T extends Number, Y extends NumberMatcher<T, ?>> {
protected Y matcher; | protected IntConsumer adder; |
brunodles/java-validation | src/test/java/MainTest.java | // Path: src/main/java/com/github/brunodles/javavalidation/ValidationResult.java
// public interface ValidationResult {
// /**
// * This is the return of the whole tests.
// *
// * @return true if didn't found any error
// */
// boolean isValid();
//
//
// /**
// * With this you can check if one key have certain error.
// *
// * @param key normaly is used the field name
// * @param error the error from {@link Errors}
// * @return true if the key contains the error
// */
// boolean contains(String key, int error);
//
// /**
// * With this you can check if the key have a error
// *
// * @param key normaly is used the field name
// * @return true if the key contains a error
// */
// boolean contains(String key);
//
// /**
// * All keys that have errors
// *
// * @return a list with all keys
// */
// List<String> keys();
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/ValidationResultBuilder.java
// public class ValidationResultBuilder implements ValidationResult {
// HashMap<String, Integer> errorMap;
//
// public ValidationResultBuilder() {
// errorMap = new HashMap<>();
// }
//
// /**
// * Use this method to add an error.
// *
// * @param key This key will be used to know what is wrong, you ca use the field name here.
// * @param error All errors are constants, use one of {@link Errors}
// */
// public void add(String key, int error) {
// Integer errors = errorsFrom(key);
// errors |= error;
// errorMap.put(key, errors);
// }
//
// /**
// * This will return one error adder for the key
// *
// * @param key the key you want to add error
// * @return a {@link IntConsumer}, to add errors on the key just call {@link IntConsumer#accept(int)}
// */
// public IntConsumer adder(String key) {
// return error -> add(key, error);
// }
//
// /**
// * With this method you can get the errors from one key
// *
// * @param key
// * @return
// */
// private Integer errorsFrom(String key) {
// Integer errors = errorMap.get(key);
// if (errors == null) errors = 0;
// return errors;
// }
//
// /**
// * Check if the object is valid
// *
// * @return true if the object don't have any error
// */
// public boolean isValid() {
// return errorMap.isEmpty();
// }
//
// /**
// * With this you can check if one key have certain error.
// *
// * @param key the same key used on {@link #add}
// * @param error the error from {@link Errors}
// * @return true if the key contains the error
// */
// @Override
// public boolean contains(String key, int error) {
// Integer errors = errorsFrom(key);
// return (errors & error) == error;
// }
//
// @Override
// public boolean contains(String key) {
// return errorsFrom(key) != 0;
// }
//
// @Override
// public List<String> keys() {
// return Collections.unmodifiableList(new ArrayList<>(errorMap.keySet()));
// }
//
// /**
// * With this you can use a builder to create all errors for one key
// *
// * @param key the key where the errors will be added
// * @return a helper to build the errors {@link When}
// */
// public When addTo(String key) {
// return new When(adder(key));
// }
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/ValidatorBase.java
// public abstract class ValidatorBase<T> implements Validator<T> {
//
// public ValidationResult validate(T object) {
// ValidationResultBuilder resultBuilder = new ValidationResultBuilder();
// validate(object, resultBuilder);
// return resultBuilder;
// }
//
// protected abstract void validate(T object, ValidationResultBuilder resultBuilder);
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
| import com.github.brunodles.javavalidation.ValidationResult;
import com.github.brunodles.javavalidation.ValidationResultBuilder;
import com.github.brunodles.javavalidation.ValidatorBase;
import com.mscharhag.oleaster.runner.OleasterRunner;
import org.junit.runner.RunWith;
import static com.github.brunodles.javavalidation.Errors.*;
import static com.mscharhag.oleaster.matcher.Matchers.expect;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.*; |
/**
* Created by bruno on 03/06/16.
*/
@RunWith(OleasterRunner.class)
public class MainTest {
private SampleValidator validator;
| // Path: src/main/java/com/github/brunodles/javavalidation/ValidationResult.java
// public interface ValidationResult {
// /**
// * This is the return of the whole tests.
// *
// * @return true if didn't found any error
// */
// boolean isValid();
//
//
// /**
// * With this you can check if one key have certain error.
// *
// * @param key normaly is used the field name
// * @param error the error from {@link Errors}
// * @return true if the key contains the error
// */
// boolean contains(String key, int error);
//
// /**
// * With this you can check if the key have a error
// *
// * @param key normaly is used the field name
// * @return true if the key contains a error
// */
// boolean contains(String key);
//
// /**
// * All keys that have errors
// *
// * @return a list with all keys
// */
// List<String> keys();
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/ValidationResultBuilder.java
// public class ValidationResultBuilder implements ValidationResult {
// HashMap<String, Integer> errorMap;
//
// public ValidationResultBuilder() {
// errorMap = new HashMap<>();
// }
//
// /**
// * Use this method to add an error.
// *
// * @param key This key will be used to know what is wrong, you ca use the field name here.
// * @param error All errors are constants, use one of {@link Errors}
// */
// public void add(String key, int error) {
// Integer errors = errorsFrom(key);
// errors |= error;
// errorMap.put(key, errors);
// }
//
// /**
// * This will return one error adder for the key
// *
// * @param key the key you want to add error
// * @return a {@link IntConsumer}, to add errors on the key just call {@link IntConsumer#accept(int)}
// */
// public IntConsumer adder(String key) {
// return error -> add(key, error);
// }
//
// /**
// * With this method you can get the errors from one key
// *
// * @param key
// * @return
// */
// private Integer errorsFrom(String key) {
// Integer errors = errorMap.get(key);
// if (errors == null) errors = 0;
// return errors;
// }
//
// /**
// * Check if the object is valid
// *
// * @return true if the object don't have any error
// */
// public boolean isValid() {
// return errorMap.isEmpty();
// }
//
// /**
// * With this you can check if one key have certain error.
// *
// * @param key the same key used on {@link #add}
// * @param error the error from {@link Errors}
// * @return true if the key contains the error
// */
// @Override
// public boolean contains(String key, int error) {
// Integer errors = errorsFrom(key);
// return (errors & error) == error;
// }
//
// @Override
// public boolean contains(String key) {
// return errorsFrom(key) != 0;
// }
//
// @Override
// public List<String> keys() {
// return Collections.unmodifiableList(new ArrayList<>(errorMap.keySet()));
// }
//
// /**
// * With this you can use a builder to create all errors for one key
// *
// * @param key the key where the errors will be added
// * @return a helper to build the errors {@link When}
// */
// public When addTo(String key) {
// return new When(adder(key));
// }
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/ValidatorBase.java
// public abstract class ValidatorBase<T> implements Validator<T> {
//
// public ValidationResult validate(T object) {
// ValidationResultBuilder resultBuilder = new ValidationResultBuilder();
// validate(object, resultBuilder);
// return resultBuilder;
// }
//
// protected abstract void validate(T object, ValidationResultBuilder resultBuilder);
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
// Path: src/test/java/MainTest.java
import com.github.brunodles.javavalidation.ValidationResult;
import com.github.brunodles.javavalidation.ValidationResultBuilder;
import com.github.brunodles.javavalidation.ValidatorBase;
import com.mscharhag.oleaster.runner.OleasterRunner;
import org.junit.runner.RunWith;
import static com.github.brunodles.javavalidation.Errors.*;
import static com.mscharhag.oleaster.matcher.Matchers.expect;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.*;
/**
* Created by bruno on 03/06/16.
*/
@RunWith(OleasterRunner.class)
public class MainTest {
private SampleValidator validator;
| private ValidationResult validation; |
brunodles/java-validation | src/test/java/MainTest.java | // Path: src/main/java/com/github/brunodles/javavalidation/ValidationResult.java
// public interface ValidationResult {
// /**
// * This is the return of the whole tests.
// *
// * @return true if didn't found any error
// */
// boolean isValid();
//
//
// /**
// * With this you can check if one key have certain error.
// *
// * @param key normaly is used the field name
// * @param error the error from {@link Errors}
// * @return true if the key contains the error
// */
// boolean contains(String key, int error);
//
// /**
// * With this you can check if the key have a error
// *
// * @param key normaly is used the field name
// * @return true if the key contains a error
// */
// boolean contains(String key);
//
// /**
// * All keys that have errors
// *
// * @return a list with all keys
// */
// List<String> keys();
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/ValidationResultBuilder.java
// public class ValidationResultBuilder implements ValidationResult {
// HashMap<String, Integer> errorMap;
//
// public ValidationResultBuilder() {
// errorMap = new HashMap<>();
// }
//
// /**
// * Use this method to add an error.
// *
// * @param key This key will be used to know what is wrong, you ca use the field name here.
// * @param error All errors are constants, use one of {@link Errors}
// */
// public void add(String key, int error) {
// Integer errors = errorsFrom(key);
// errors |= error;
// errorMap.put(key, errors);
// }
//
// /**
// * This will return one error adder for the key
// *
// * @param key the key you want to add error
// * @return a {@link IntConsumer}, to add errors on the key just call {@link IntConsumer#accept(int)}
// */
// public IntConsumer adder(String key) {
// return error -> add(key, error);
// }
//
// /**
// * With this method you can get the errors from one key
// *
// * @param key
// * @return
// */
// private Integer errorsFrom(String key) {
// Integer errors = errorMap.get(key);
// if (errors == null) errors = 0;
// return errors;
// }
//
// /**
// * Check if the object is valid
// *
// * @return true if the object don't have any error
// */
// public boolean isValid() {
// return errorMap.isEmpty();
// }
//
// /**
// * With this you can check if one key have certain error.
// *
// * @param key the same key used on {@link #add}
// * @param error the error from {@link Errors}
// * @return true if the key contains the error
// */
// @Override
// public boolean contains(String key, int error) {
// Integer errors = errorsFrom(key);
// return (errors & error) == error;
// }
//
// @Override
// public boolean contains(String key) {
// return errorsFrom(key) != 0;
// }
//
// @Override
// public List<String> keys() {
// return Collections.unmodifiableList(new ArrayList<>(errorMap.keySet()));
// }
//
// /**
// * With this you can use a builder to create all errors for one key
// *
// * @param key the key where the errors will be added
// * @return a helper to build the errors {@link When}
// */
// public When addTo(String key) {
// return new When(adder(key));
// }
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/ValidatorBase.java
// public abstract class ValidatorBase<T> implements Validator<T> {
//
// public ValidationResult validate(T object) {
// ValidationResultBuilder resultBuilder = new ValidationResultBuilder();
// validate(object, resultBuilder);
// return resultBuilder;
// }
//
// protected abstract void validate(T object, ValidationResultBuilder resultBuilder);
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
| import com.github.brunodles.javavalidation.ValidationResult;
import com.github.brunodles.javavalidation.ValidationResultBuilder;
import com.github.brunodles.javavalidation.ValidatorBase;
import com.mscharhag.oleaster.runner.OleasterRunner;
import org.junit.runner.RunWith;
import static com.github.brunodles.javavalidation.Errors.*;
import static com.mscharhag.oleaster.matcher.Matchers.expect;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.*; | SampleClass sample = new SampleClass();
validation = validator.validate(sample);
});
it("should not add NULL on strikeCount errors", () -> {
expect(validation.contains("strikeCount", NULL)).toBeFalse();
});
describe("when contains the wrong value", () -> {
before(() -> {
SampleClass sample = new SampleClass();
sample.strikeCount = 7;
validation = validator.validate(sample);
});
it("should add GREATER on strikeCount errors", () -> {
expect(validation.contains("strikeCount", GREATER)).toBeTrue();
});
});
});
});
}
private static class SampleClass {
String name;
int strikeCount;
}
| // Path: src/main/java/com/github/brunodles/javavalidation/ValidationResult.java
// public interface ValidationResult {
// /**
// * This is the return of the whole tests.
// *
// * @return true if didn't found any error
// */
// boolean isValid();
//
//
// /**
// * With this you can check if one key have certain error.
// *
// * @param key normaly is used the field name
// * @param error the error from {@link Errors}
// * @return true if the key contains the error
// */
// boolean contains(String key, int error);
//
// /**
// * With this you can check if the key have a error
// *
// * @param key normaly is used the field name
// * @return true if the key contains a error
// */
// boolean contains(String key);
//
// /**
// * All keys that have errors
// *
// * @return a list with all keys
// */
// List<String> keys();
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/ValidationResultBuilder.java
// public class ValidationResultBuilder implements ValidationResult {
// HashMap<String, Integer> errorMap;
//
// public ValidationResultBuilder() {
// errorMap = new HashMap<>();
// }
//
// /**
// * Use this method to add an error.
// *
// * @param key This key will be used to know what is wrong, you ca use the field name here.
// * @param error All errors are constants, use one of {@link Errors}
// */
// public void add(String key, int error) {
// Integer errors = errorsFrom(key);
// errors |= error;
// errorMap.put(key, errors);
// }
//
// /**
// * This will return one error adder for the key
// *
// * @param key the key you want to add error
// * @return a {@link IntConsumer}, to add errors on the key just call {@link IntConsumer#accept(int)}
// */
// public IntConsumer adder(String key) {
// return error -> add(key, error);
// }
//
// /**
// * With this method you can get the errors from one key
// *
// * @param key
// * @return
// */
// private Integer errorsFrom(String key) {
// Integer errors = errorMap.get(key);
// if (errors == null) errors = 0;
// return errors;
// }
//
// /**
// * Check if the object is valid
// *
// * @return true if the object don't have any error
// */
// public boolean isValid() {
// return errorMap.isEmpty();
// }
//
// /**
// * With this you can check if one key have certain error.
// *
// * @param key the same key used on {@link #add}
// * @param error the error from {@link Errors}
// * @return true if the key contains the error
// */
// @Override
// public boolean contains(String key, int error) {
// Integer errors = errorsFrom(key);
// return (errors & error) == error;
// }
//
// @Override
// public boolean contains(String key) {
// return errorsFrom(key) != 0;
// }
//
// @Override
// public List<String> keys() {
// return Collections.unmodifiableList(new ArrayList<>(errorMap.keySet()));
// }
//
// /**
// * With this you can use a builder to create all errors for one key
// *
// * @param key the key where the errors will be added
// * @return a helper to build the errors {@link When}
// */
// public When addTo(String key) {
// return new When(adder(key));
// }
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/ValidatorBase.java
// public abstract class ValidatorBase<T> implements Validator<T> {
//
// public ValidationResult validate(T object) {
// ValidationResultBuilder resultBuilder = new ValidationResultBuilder();
// validate(object, resultBuilder);
// return resultBuilder;
// }
//
// protected abstract void validate(T object, ValidationResultBuilder resultBuilder);
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
// Path: src/test/java/MainTest.java
import com.github.brunodles.javavalidation.ValidationResult;
import com.github.brunodles.javavalidation.ValidationResultBuilder;
import com.github.brunodles.javavalidation.ValidatorBase;
import com.mscharhag.oleaster.runner.OleasterRunner;
import org.junit.runner.RunWith;
import static com.github.brunodles.javavalidation.Errors.*;
import static com.mscharhag.oleaster.matcher.Matchers.expect;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.*;
SampleClass sample = new SampleClass();
validation = validator.validate(sample);
});
it("should not add NULL on strikeCount errors", () -> {
expect(validation.contains("strikeCount", NULL)).toBeFalse();
});
describe("when contains the wrong value", () -> {
before(() -> {
SampleClass sample = new SampleClass();
sample.strikeCount = 7;
validation = validator.validate(sample);
});
it("should add GREATER on strikeCount errors", () -> {
expect(validation.contains("strikeCount", GREATER)).toBeTrue();
});
});
});
});
}
private static class SampleClass {
String name;
int strikeCount;
}
| private static class SampleValidator extends ValidatorBase<SampleClass> { |
brunodles/java-validation | src/test/java/MainTest.java | // Path: src/main/java/com/github/brunodles/javavalidation/ValidationResult.java
// public interface ValidationResult {
// /**
// * This is the return of the whole tests.
// *
// * @return true if didn't found any error
// */
// boolean isValid();
//
//
// /**
// * With this you can check if one key have certain error.
// *
// * @param key normaly is used the field name
// * @param error the error from {@link Errors}
// * @return true if the key contains the error
// */
// boolean contains(String key, int error);
//
// /**
// * With this you can check if the key have a error
// *
// * @param key normaly is used the field name
// * @return true if the key contains a error
// */
// boolean contains(String key);
//
// /**
// * All keys that have errors
// *
// * @return a list with all keys
// */
// List<String> keys();
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/ValidationResultBuilder.java
// public class ValidationResultBuilder implements ValidationResult {
// HashMap<String, Integer> errorMap;
//
// public ValidationResultBuilder() {
// errorMap = new HashMap<>();
// }
//
// /**
// * Use this method to add an error.
// *
// * @param key This key will be used to know what is wrong, you ca use the field name here.
// * @param error All errors are constants, use one of {@link Errors}
// */
// public void add(String key, int error) {
// Integer errors = errorsFrom(key);
// errors |= error;
// errorMap.put(key, errors);
// }
//
// /**
// * This will return one error adder for the key
// *
// * @param key the key you want to add error
// * @return a {@link IntConsumer}, to add errors on the key just call {@link IntConsumer#accept(int)}
// */
// public IntConsumer adder(String key) {
// return error -> add(key, error);
// }
//
// /**
// * With this method you can get the errors from one key
// *
// * @param key
// * @return
// */
// private Integer errorsFrom(String key) {
// Integer errors = errorMap.get(key);
// if (errors == null) errors = 0;
// return errors;
// }
//
// /**
// * Check if the object is valid
// *
// * @return true if the object don't have any error
// */
// public boolean isValid() {
// return errorMap.isEmpty();
// }
//
// /**
// * With this you can check if one key have certain error.
// *
// * @param key the same key used on {@link #add}
// * @param error the error from {@link Errors}
// * @return true if the key contains the error
// */
// @Override
// public boolean contains(String key, int error) {
// Integer errors = errorsFrom(key);
// return (errors & error) == error;
// }
//
// @Override
// public boolean contains(String key) {
// return errorsFrom(key) != 0;
// }
//
// @Override
// public List<String> keys() {
// return Collections.unmodifiableList(new ArrayList<>(errorMap.keySet()));
// }
//
// /**
// * With this you can use a builder to create all errors for one key
// *
// * @param key the key where the errors will be added
// * @return a helper to build the errors {@link When}
// */
// public When addTo(String key) {
// return new When(adder(key));
// }
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/ValidatorBase.java
// public abstract class ValidatorBase<T> implements Validator<T> {
//
// public ValidationResult validate(T object) {
// ValidationResultBuilder resultBuilder = new ValidationResultBuilder();
// validate(object, resultBuilder);
// return resultBuilder;
// }
//
// protected abstract void validate(T object, ValidationResultBuilder resultBuilder);
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
| import com.github.brunodles.javavalidation.ValidationResult;
import com.github.brunodles.javavalidation.ValidationResultBuilder;
import com.github.brunodles.javavalidation.ValidatorBase;
import com.mscharhag.oleaster.runner.OleasterRunner;
import org.junit.runner.RunWith;
import static com.github.brunodles.javavalidation.Errors.*;
import static com.mscharhag.oleaster.matcher.Matchers.expect;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.*; | });
it("should not add NULL on strikeCount errors", () -> {
expect(validation.contains("strikeCount", NULL)).toBeFalse();
});
describe("when contains the wrong value", () -> {
before(() -> {
SampleClass sample = new SampleClass();
sample.strikeCount = 7;
validation = validator.validate(sample);
});
it("should add GREATER on strikeCount errors", () -> {
expect(validation.contains("strikeCount", GREATER)).toBeTrue();
});
});
});
});
}
private static class SampleClass {
String name;
int strikeCount;
}
private static class SampleValidator extends ValidatorBase<SampleClass> {
@Override | // Path: src/main/java/com/github/brunodles/javavalidation/ValidationResult.java
// public interface ValidationResult {
// /**
// * This is the return of the whole tests.
// *
// * @return true if didn't found any error
// */
// boolean isValid();
//
//
// /**
// * With this you can check if one key have certain error.
// *
// * @param key normaly is used the field name
// * @param error the error from {@link Errors}
// * @return true if the key contains the error
// */
// boolean contains(String key, int error);
//
// /**
// * With this you can check if the key have a error
// *
// * @param key normaly is used the field name
// * @return true if the key contains a error
// */
// boolean contains(String key);
//
// /**
// * All keys that have errors
// *
// * @return a list with all keys
// */
// List<String> keys();
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/ValidationResultBuilder.java
// public class ValidationResultBuilder implements ValidationResult {
// HashMap<String, Integer> errorMap;
//
// public ValidationResultBuilder() {
// errorMap = new HashMap<>();
// }
//
// /**
// * Use this method to add an error.
// *
// * @param key This key will be used to know what is wrong, you ca use the field name here.
// * @param error All errors are constants, use one of {@link Errors}
// */
// public void add(String key, int error) {
// Integer errors = errorsFrom(key);
// errors |= error;
// errorMap.put(key, errors);
// }
//
// /**
// * This will return one error adder for the key
// *
// * @param key the key you want to add error
// * @return a {@link IntConsumer}, to add errors on the key just call {@link IntConsumer#accept(int)}
// */
// public IntConsumer adder(String key) {
// return error -> add(key, error);
// }
//
// /**
// * With this method you can get the errors from one key
// *
// * @param key
// * @return
// */
// private Integer errorsFrom(String key) {
// Integer errors = errorMap.get(key);
// if (errors == null) errors = 0;
// return errors;
// }
//
// /**
// * Check if the object is valid
// *
// * @return true if the object don't have any error
// */
// public boolean isValid() {
// return errorMap.isEmpty();
// }
//
// /**
// * With this you can check if one key have certain error.
// *
// * @param key the same key used on {@link #add}
// * @param error the error from {@link Errors}
// * @return true if the key contains the error
// */
// @Override
// public boolean contains(String key, int error) {
// Integer errors = errorsFrom(key);
// return (errors & error) == error;
// }
//
// @Override
// public boolean contains(String key) {
// return errorsFrom(key) != 0;
// }
//
// @Override
// public List<String> keys() {
// return Collections.unmodifiableList(new ArrayList<>(errorMap.keySet()));
// }
//
// /**
// * With this you can use a builder to create all errors for one key
// *
// * @param key the key where the errors will be added
// * @return a helper to build the errors {@link When}
// */
// public When addTo(String key) {
// return new When(adder(key));
// }
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/ValidatorBase.java
// public abstract class ValidatorBase<T> implements Validator<T> {
//
// public ValidationResult validate(T object) {
// ValidationResultBuilder resultBuilder = new ValidationResultBuilder();
// validate(object, resultBuilder);
// return resultBuilder;
// }
//
// protected abstract void validate(T object, ValidationResultBuilder resultBuilder);
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
// Path: src/test/java/MainTest.java
import com.github.brunodles.javavalidation.ValidationResult;
import com.github.brunodles.javavalidation.ValidationResultBuilder;
import com.github.brunodles.javavalidation.ValidatorBase;
import com.mscharhag.oleaster.runner.OleasterRunner;
import org.junit.runner.RunWith;
import static com.github.brunodles.javavalidation.Errors.*;
import static com.mscharhag.oleaster.matcher.Matchers.expect;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.*;
});
it("should not add NULL on strikeCount errors", () -> {
expect(validation.contains("strikeCount", NULL)).toBeFalse();
});
describe("when contains the wrong value", () -> {
before(() -> {
SampleClass sample = new SampleClass();
sample.strikeCount = 7;
validation = validator.validate(sample);
});
it("should add GREATER on strikeCount errors", () -> {
expect(validation.contains("strikeCount", GREATER)).toBeTrue();
});
});
});
});
}
private static class SampleClass {
String name;
int strikeCount;
}
private static class SampleValidator extends ValidatorBase<SampleClass> {
@Override | protected void validate(SampleClass object, ValidationResultBuilder builder) { |
brunodles/java-validation | src/test/java/com/github/brunodles/javavalidation/matcher/FloatMatcherTest.java | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
| import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import com.mscharhag.oleaster.runner.OleasterRunner;
import org.junit.runner.RunWith;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.before;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.describe;
import static org.mockito.Mockito.mock; | package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 04/06/16.
*/
@RunWith(OleasterRunner.class)
public class FloatMatcherTest extends NumberMatcherTestBase<Float, FloatMatcher> {
{
describe("Given a IntegerMatcher for 7", () -> {
before(() -> { | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
// Path: src/test/java/com/github/brunodles/javavalidation/matcher/FloatMatcherTest.java
import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import com.mscharhag.oleaster.runner.OleasterRunner;
import org.junit.runner.RunWith;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.before;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.describe;
import static org.mockito.Mockito.mock;
package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 04/06/16.
*/
@RunWith(OleasterRunner.class)
public class FloatMatcherTest extends NumberMatcherTestBase<Float, FloatMatcher> {
{
describe("Given a IntegerMatcher for 7", () -> {
before(() -> { | adder = mock(IntConsumer.class); |
brunodles/java-validation | src/test/java/com/github/brunodles/javavalidation/matcher/FloatMatcherTest.java | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
| import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import com.mscharhag.oleaster.runner.OleasterRunner;
import org.junit.runner.RunWith;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.before;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.describe;
import static org.mockito.Mockito.mock; | package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 04/06/16.
*/
@RunWith(OleasterRunner.class)
public class FloatMatcherTest extends NumberMatcherTestBase<Float, FloatMatcher> {
{
describe("Given a IntegerMatcher for 7", () -> {
before(() -> {
adder = mock(IntConsumer.class);
matcher = new FloatMatcher(7F, adder);
});
describe("when call isBetween", () -> {
when_isBetween(1F, 7F, this::itShouldNotCallAdder);
when_isBetween(7F, 10F, this::itShouldNotCallAdder); | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
// Path: src/test/java/com/github/brunodles/javavalidation/matcher/FloatMatcherTest.java
import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import com.mscharhag.oleaster.runner.OleasterRunner;
import org.junit.runner.RunWith;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.before;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.describe;
import static org.mockito.Mockito.mock;
package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 04/06/16.
*/
@RunWith(OleasterRunner.class)
public class FloatMatcherTest extends NumberMatcherTestBase<Float, FloatMatcher> {
{
describe("Given a IntegerMatcher for 7", () -> {
before(() -> {
adder = mock(IntConsumer.class);
matcher = new FloatMatcher(7F, adder);
});
describe("when call isBetween", () -> {
when_isBetween(1F, 7F, this::itShouldNotCallAdder);
when_isBetween(7F, 10F, this::itShouldNotCallAdder); | when_isBetween(5F, 9F, () -> itShouldCallAdderWith("BETWEEN", Errors.BETWEEN)); |
brunodles/java-validation | src/main/java/com/github/brunodles/javavalidation/matcher/BooleanMatcher.java | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/matcher/Common.java
// static void _if(BooleanSupplier condition, IntConsumer block, int error) {
// try {
// if (condition.getAsBoolean()) block.accept(error);
// } catch (Exception e) {
// }
// }
| import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import static com.github.brunodles.javavalidation.matcher.Common._if; | package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 04/06/16.
*/
public class BooleanMatcher implements ObjectMatcher<Boolean, BooleanMatcher> {
Boolean value; | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/matcher/Common.java
// static void _if(BooleanSupplier condition, IntConsumer block, int error) {
// try {
// if (condition.getAsBoolean()) block.accept(error);
// } catch (Exception e) {
// }
// }
// Path: src/main/java/com/github/brunodles/javavalidation/matcher/BooleanMatcher.java
import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import static com.github.brunodles.javavalidation.matcher.Common._if;
package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 04/06/16.
*/
public class BooleanMatcher implements ObjectMatcher<Boolean, BooleanMatcher> {
Boolean value; | IntConsumer adder; |
brunodles/java-validation | src/main/java/com/github/brunodles/javavalidation/matcher/BooleanMatcher.java | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/matcher/Common.java
// static void _if(BooleanSupplier condition, IntConsumer block, int error) {
// try {
// if (condition.getAsBoolean()) block.accept(error);
// } catch (Exception e) {
// }
// }
| import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import static com.github.brunodles.javavalidation.matcher.Common._if; | package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 04/06/16.
*/
public class BooleanMatcher implements ObjectMatcher<Boolean, BooleanMatcher> {
Boolean value;
IntConsumer adder;
public BooleanMatcher(Boolean value, IntConsumer adder) {
this.value = value;
this.adder = adder;
}
/**
* Check if the reference value is true
*
* @return the current object, to be used as a builder
*/
public BooleanMatcher isTrue() { | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/matcher/Common.java
// static void _if(BooleanSupplier condition, IntConsumer block, int error) {
// try {
// if (condition.getAsBoolean()) block.accept(error);
// } catch (Exception e) {
// }
// }
// Path: src/main/java/com/github/brunodles/javavalidation/matcher/BooleanMatcher.java
import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import static com.github.brunodles.javavalidation.matcher.Common._if;
package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 04/06/16.
*/
public class BooleanMatcher implements ObjectMatcher<Boolean, BooleanMatcher> {
Boolean value;
IntConsumer adder;
public BooleanMatcher(Boolean value, IntConsumer adder) {
this.value = value;
this.adder = adder;
}
/**
* Check if the reference value is true
*
* @return the current object, to be used as a builder
*/
public BooleanMatcher isTrue() { | _if(() -> value, adder, Errors.TRUE); |
brunodles/java-validation | src/main/java/com/github/brunodles/javavalidation/matcher/BooleanMatcher.java | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/matcher/Common.java
// static void _if(BooleanSupplier condition, IntConsumer block, int error) {
// try {
// if (condition.getAsBoolean()) block.accept(error);
// } catch (Exception e) {
// }
// }
| import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import static com.github.brunodles.javavalidation.matcher.Common._if; | package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 04/06/16.
*/
public class BooleanMatcher implements ObjectMatcher<Boolean, BooleanMatcher> {
Boolean value;
IntConsumer adder;
public BooleanMatcher(Boolean value, IntConsumer adder) {
this.value = value;
this.adder = adder;
}
/**
* Check if the reference value is true
*
* @return the current object, to be used as a builder
*/
public BooleanMatcher isTrue() { | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/matcher/Common.java
// static void _if(BooleanSupplier condition, IntConsumer block, int error) {
// try {
// if (condition.getAsBoolean()) block.accept(error);
// } catch (Exception e) {
// }
// }
// Path: src/main/java/com/github/brunodles/javavalidation/matcher/BooleanMatcher.java
import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import static com.github.brunodles.javavalidation.matcher.Common._if;
package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 04/06/16.
*/
public class BooleanMatcher implements ObjectMatcher<Boolean, BooleanMatcher> {
Boolean value;
IntConsumer adder;
public BooleanMatcher(Boolean value, IntConsumer adder) {
this.value = value;
this.adder = adder;
}
/**
* Check if the reference value is true
*
* @return the current object, to be used as a builder
*/
public BooleanMatcher isTrue() { | _if(() -> value, adder, Errors.TRUE); |
brunodles/java-validation | src/main/java/com/github/brunodles/javavalidation/ValidationResultBuilder.java | // Path: src/main/java/com/github/brunodles/javavalidation/matcher/When.java
// public class When {
//
// private IntConsumer adder;
//
// public When(IntConsumer adder) {
// this.adder = adder;
// }
//
// /**
// * @param value a String to be the reference value
// * @return a {@link StringMatcher}
// */
// public StringMatcher when(String value) {
// return new StringMatcher(value, adder);
// }
//
// /**
// * @param value a Integer to be the reference value
// * @return a {@link IntegerMatcher}
// */
// public IntegerMatcher when(Integer value) {
// return new IntegerMatcher(value, adder);
// }
//
// /**
// * @param value a Long to be the reference value
// * @return a {@link LongMatcher}
// */
// public LongMatcher when(Long value) {
// return new LongMatcher(value, adder);
// }
//
// /**
// * @param value a Float to be the reference value
// * @return a {@link FloatMatcher}
// */
// public FloatMatcher when(Float value) {
// return new FloatMatcher(value, adder);
// }
//
// /**
// * @param value a Double to be the reference value
// * @return a {@link DoubleMatcher}
// */
// public DoubleMatcher when(Double value) {
// return new DoubleMatcher(value, adder);
// }
//
// /**
// * @param object a Object to be the reference value
// * @param <T> Don't need to worry with this parameter it will be auto inferred by compiler
// * @return a {@link ObjectMatcher}
// */
// public <T> ObjectMatcher<T, ?> when(final T object) {
// return new ObjectMatcherImpl<T>(object, adder);
// }
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
| import com.github.brunodles.javavalidation.matcher.When;
import com.github.brunodles.retrofunctions.IntConsumer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List; | package com.github.brunodles.javavalidation;
/**
* This builder will be used inside the validator to create all validations.
* Created by bruno on 03/06/16.
*/
public class ValidationResultBuilder implements ValidationResult {
HashMap<String, Integer> errorMap;
public ValidationResultBuilder() {
errorMap = new HashMap<>();
}
/**
* Use this method to add an error.
*
* @param key This key will be used to know what is wrong, you ca use the field name here.
* @param error All errors are constants, use one of {@link Errors}
*/
public void add(String key, int error) {
Integer errors = errorsFrom(key);
errors |= error;
errorMap.put(key, errors);
}
/**
* This will return one error adder for the key
*
* @param key the key you want to add error
* @return a {@link IntConsumer}, to add errors on the key just call {@link IntConsumer#accept(int)}
*/ | // Path: src/main/java/com/github/brunodles/javavalidation/matcher/When.java
// public class When {
//
// private IntConsumer adder;
//
// public When(IntConsumer adder) {
// this.adder = adder;
// }
//
// /**
// * @param value a String to be the reference value
// * @return a {@link StringMatcher}
// */
// public StringMatcher when(String value) {
// return new StringMatcher(value, adder);
// }
//
// /**
// * @param value a Integer to be the reference value
// * @return a {@link IntegerMatcher}
// */
// public IntegerMatcher when(Integer value) {
// return new IntegerMatcher(value, adder);
// }
//
// /**
// * @param value a Long to be the reference value
// * @return a {@link LongMatcher}
// */
// public LongMatcher when(Long value) {
// return new LongMatcher(value, adder);
// }
//
// /**
// * @param value a Float to be the reference value
// * @return a {@link FloatMatcher}
// */
// public FloatMatcher when(Float value) {
// return new FloatMatcher(value, adder);
// }
//
// /**
// * @param value a Double to be the reference value
// * @return a {@link DoubleMatcher}
// */
// public DoubleMatcher when(Double value) {
// return new DoubleMatcher(value, adder);
// }
//
// /**
// * @param object a Object to be the reference value
// * @param <T> Don't need to worry with this parameter it will be auto inferred by compiler
// * @return a {@link ObjectMatcher}
// */
// public <T> ObjectMatcher<T, ?> when(final T object) {
// return new ObjectMatcherImpl<T>(object, adder);
// }
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
// Path: src/main/java/com/github/brunodles/javavalidation/ValidationResultBuilder.java
import com.github.brunodles.javavalidation.matcher.When;
import com.github.brunodles.retrofunctions.IntConsumer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
package com.github.brunodles.javavalidation;
/**
* This builder will be used inside the validator to create all validations.
* Created by bruno on 03/06/16.
*/
public class ValidationResultBuilder implements ValidationResult {
HashMap<String, Integer> errorMap;
public ValidationResultBuilder() {
errorMap = new HashMap<>();
}
/**
* Use this method to add an error.
*
* @param key This key will be used to know what is wrong, you ca use the field name here.
* @param error All errors are constants, use one of {@link Errors}
*/
public void add(String key, int error) {
Integer errors = errorsFrom(key);
errors |= error;
errorMap.put(key, errors);
}
/**
* This will return one error adder for the key
*
* @param key the key you want to add error
* @return a {@link IntConsumer}, to add errors on the key just call {@link IntConsumer#accept(int)}
*/ | public IntConsumer adder(String key) { |
brunodles/java-validation | src/main/java/com/github/brunodles/javavalidation/ValidationResultBuilder.java | // Path: src/main/java/com/github/brunodles/javavalidation/matcher/When.java
// public class When {
//
// private IntConsumer adder;
//
// public When(IntConsumer adder) {
// this.adder = adder;
// }
//
// /**
// * @param value a String to be the reference value
// * @return a {@link StringMatcher}
// */
// public StringMatcher when(String value) {
// return new StringMatcher(value, adder);
// }
//
// /**
// * @param value a Integer to be the reference value
// * @return a {@link IntegerMatcher}
// */
// public IntegerMatcher when(Integer value) {
// return new IntegerMatcher(value, adder);
// }
//
// /**
// * @param value a Long to be the reference value
// * @return a {@link LongMatcher}
// */
// public LongMatcher when(Long value) {
// return new LongMatcher(value, adder);
// }
//
// /**
// * @param value a Float to be the reference value
// * @return a {@link FloatMatcher}
// */
// public FloatMatcher when(Float value) {
// return new FloatMatcher(value, adder);
// }
//
// /**
// * @param value a Double to be the reference value
// * @return a {@link DoubleMatcher}
// */
// public DoubleMatcher when(Double value) {
// return new DoubleMatcher(value, adder);
// }
//
// /**
// * @param object a Object to be the reference value
// * @param <T> Don't need to worry with this parameter it will be auto inferred by compiler
// * @return a {@link ObjectMatcher}
// */
// public <T> ObjectMatcher<T, ?> when(final T object) {
// return new ObjectMatcherImpl<T>(object, adder);
// }
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
| import com.github.brunodles.javavalidation.matcher.When;
import com.github.brunodles.retrofunctions.IntConsumer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List; |
/**
* With this you can check if one key have certain error.
*
* @param key the same key used on {@link #add}
* @param error the error from {@link Errors}
* @return true if the key contains the error
*/
@Override
public boolean contains(String key, int error) {
Integer errors = errorsFrom(key);
return (errors & error) == error;
}
@Override
public boolean contains(String key) {
return errorsFrom(key) != 0;
}
@Override
public List<String> keys() {
return Collections.unmodifiableList(new ArrayList<>(errorMap.keySet()));
}
/**
* With this you can use a builder to create all errors for one key
*
* @param key the key where the errors will be added
* @return a helper to build the errors {@link When}
*/ | // Path: src/main/java/com/github/brunodles/javavalidation/matcher/When.java
// public class When {
//
// private IntConsumer adder;
//
// public When(IntConsumer adder) {
// this.adder = adder;
// }
//
// /**
// * @param value a String to be the reference value
// * @return a {@link StringMatcher}
// */
// public StringMatcher when(String value) {
// return new StringMatcher(value, adder);
// }
//
// /**
// * @param value a Integer to be the reference value
// * @return a {@link IntegerMatcher}
// */
// public IntegerMatcher when(Integer value) {
// return new IntegerMatcher(value, adder);
// }
//
// /**
// * @param value a Long to be the reference value
// * @return a {@link LongMatcher}
// */
// public LongMatcher when(Long value) {
// return new LongMatcher(value, adder);
// }
//
// /**
// * @param value a Float to be the reference value
// * @return a {@link FloatMatcher}
// */
// public FloatMatcher when(Float value) {
// return new FloatMatcher(value, adder);
// }
//
// /**
// * @param value a Double to be the reference value
// * @return a {@link DoubleMatcher}
// */
// public DoubleMatcher when(Double value) {
// return new DoubleMatcher(value, adder);
// }
//
// /**
// * @param object a Object to be the reference value
// * @param <T> Don't need to worry with this parameter it will be auto inferred by compiler
// * @return a {@link ObjectMatcher}
// */
// public <T> ObjectMatcher<T, ?> when(final T object) {
// return new ObjectMatcherImpl<T>(object, adder);
// }
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
// Path: src/main/java/com/github/brunodles/javavalidation/ValidationResultBuilder.java
import com.github.brunodles.javavalidation.matcher.When;
import com.github.brunodles.retrofunctions.IntConsumer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
/**
* With this you can check if one key have certain error.
*
* @param key the same key used on {@link #add}
* @param error the error from {@link Errors}
* @return true if the key contains the error
*/
@Override
public boolean contains(String key, int error) {
Integer errors = errorsFrom(key);
return (errors & error) == error;
}
@Override
public boolean contains(String key) {
return errorsFrom(key) != 0;
}
@Override
public List<String> keys() {
return Collections.unmodifiableList(new ArrayList<>(errorMap.keySet()));
}
/**
* With this you can use a builder to create all errors for one key
*
* @param key the key where the errors will be added
* @return a helper to build the errors {@link When}
*/ | public When addTo(String key) { |
brunodles/java-validation | src/main/java/com/github/brunodles/javavalidation/matcher/ObjectMatcherImpl.java | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/matcher/Common.java
// static void _if(BooleanSupplier condition, IntConsumer block, int error) {
// try {
// if (condition.getAsBoolean()) block.accept(error);
// } catch (Exception e) {
// }
// }
| import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import static com.github.brunodles.javavalidation.matcher.Common._if; | package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 04/06/16.
*/
public class ObjectMatcherImpl<T> implements ObjectMatcher<T, ObjectMatcherImpl> {
private T value; | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/matcher/Common.java
// static void _if(BooleanSupplier condition, IntConsumer block, int error) {
// try {
// if (condition.getAsBoolean()) block.accept(error);
// } catch (Exception e) {
// }
// }
// Path: src/main/java/com/github/brunodles/javavalidation/matcher/ObjectMatcherImpl.java
import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import static com.github.brunodles.javavalidation.matcher.Common._if;
package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 04/06/16.
*/
public class ObjectMatcherImpl<T> implements ObjectMatcher<T, ObjectMatcherImpl> {
private T value; | private IntConsumer adder; |
brunodles/java-validation | src/main/java/com/github/brunodles/javavalidation/matcher/ObjectMatcherImpl.java | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/matcher/Common.java
// static void _if(BooleanSupplier condition, IntConsumer block, int error) {
// try {
// if (condition.getAsBoolean()) block.accept(error);
// } catch (Exception e) {
// }
// }
| import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import static com.github.brunodles.javavalidation.matcher.Common._if; | package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 04/06/16.
*/
public class ObjectMatcherImpl<T> implements ObjectMatcher<T, ObjectMatcherImpl> {
private T value;
private IntConsumer adder;
public ObjectMatcherImpl(T value, IntConsumer adder) {
this.value = value;
this.adder = adder;
}
@Override
public ObjectMatcherImpl isNull() { | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/matcher/Common.java
// static void _if(BooleanSupplier condition, IntConsumer block, int error) {
// try {
// if (condition.getAsBoolean()) block.accept(error);
// } catch (Exception e) {
// }
// }
// Path: src/main/java/com/github/brunodles/javavalidation/matcher/ObjectMatcherImpl.java
import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import static com.github.brunodles.javavalidation.matcher.Common._if;
package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 04/06/16.
*/
public class ObjectMatcherImpl<T> implements ObjectMatcher<T, ObjectMatcherImpl> {
private T value;
private IntConsumer adder;
public ObjectMatcherImpl(T value, IntConsumer adder) {
this.value = value;
this.adder = adder;
}
@Override
public ObjectMatcherImpl isNull() { | _if(() -> value == null, adder, Errors.NULL); |
brunodles/java-validation | src/main/java/com/github/brunodles/javavalidation/matcher/ObjectMatcherImpl.java | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/matcher/Common.java
// static void _if(BooleanSupplier condition, IntConsumer block, int error) {
// try {
// if (condition.getAsBoolean()) block.accept(error);
// } catch (Exception e) {
// }
// }
| import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import static com.github.brunodles.javavalidation.matcher.Common._if; | package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 04/06/16.
*/
public class ObjectMatcherImpl<T> implements ObjectMatcher<T, ObjectMatcherImpl> {
private T value;
private IntConsumer adder;
public ObjectMatcherImpl(T value, IntConsumer adder) {
this.value = value;
this.adder = adder;
}
@Override
public ObjectMatcherImpl isNull() { | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
//
// Path: src/main/java/com/github/brunodles/javavalidation/matcher/Common.java
// static void _if(BooleanSupplier condition, IntConsumer block, int error) {
// try {
// if (condition.getAsBoolean()) block.accept(error);
// } catch (Exception e) {
// }
// }
// Path: src/main/java/com/github/brunodles/javavalidation/matcher/ObjectMatcherImpl.java
import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import static com.github.brunodles.javavalidation.matcher.Common._if;
package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 04/06/16.
*/
public class ObjectMatcherImpl<T> implements ObjectMatcher<T, ObjectMatcherImpl> {
private T value;
private IntConsumer adder;
public ObjectMatcherImpl(T value, IntConsumer adder) {
this.value = value;
this.adder = adder;
}
@Override
public ObjectMatcherImpl isNull() { | _if(() -> value == null, adder, Errors.NULL); |
brunodles/java-validation | src/test/java/com/github/brunodles/javavalidation/matcher/LongMatcherTest.java | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
| import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import com.mscharhag.oleaster.runner.OleasterRunner;
import org.junit.runner.RunWith;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.before;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.describe;
import static org.mockito.Mockito.mock; | package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 04/06/16.
*/
@RunWith(OleasterRunner.class)
public class LongMatcherTest extends NumberMatcherTestBase<Long, LongMatcher> {
{
describe("Given a IntegerMatcher for 7", () -> {
before(() -> { | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
// Path: src/test/java/com/github/brunodles/javavalidation/matcher/LongMatcherTest.java
import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import com.mscharhag.oleaster.runner.OleasterRunner;
import org.junit.runner.RunWith;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.before;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.describe;
import static org.mockito.Mockito.mock;
package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 04/06/16.
*/
@RunWith(OleasterRunner.class)
public class LongMatcherTest extends NumberMatcherTestBase<Long, LongMatcher> {
{
describe("Given a IntegerMatcher for 7", () -> {
before(() -> { | adder = mock(IntConsumer.class); |
brunodles/java-validation | src/test/java/com/github/brunodles/javavalidation/matcher/LongMatcherTest.java | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
| import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import com.mscharhag.oleaster.runner.OleasterRunner;
import org.junit.runner.RunWith;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.before;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.describe;
import static org.mockito.Mockito.mock; | package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 04/06/16.
*/
@RunWith(OleasterRunner.class)
public class LongMatcherTest extends NumberMatcherTestBase<Long, LongMatcher> {
{
describe("Given a IntegerMatcher for 7", () -> {
before(() -> {
adder = mock(IntConsumer.class);
matcher = new LongMatcher(7L, adder);
});
describe("when call isBetween", () -> {
when_isBetween(1L, 7L, this::itShouldNotCallAdder);
when_isBetween(7L, 10L, this::itShouldNotCallAdder); | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
// Path: src/test/java/com/github/brunodles/javavalidation/matcher/LongMatcherTest.java
import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import com.mscharhag.oleaster.runner.OleasterRunner;
import org.junit.runner.RunWith;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.before;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.describe;
import static org.mockito.Mockito.mock;
package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 04/06/16.
*/
@RunWith(OleasterRunner.class)
public class LongMatcherTest extends NumberMatcherTestBase<Long, LongMatcher> {
{
describe("Given a IntegerMatcher for 7", () -> {
before(() -> {
adder = mock(IntConsumer.class);
matcher = new LongMatcher(7L, adder);
});
describe("when call isBetween", () -> {
when_isBetween(1L, 7L, this::itShouldNotCallAdder);
when_isBetween(7L, 10L, this::itShouldNotCallAdder); | when_isBetween(5L, 9L, () -> itShouldCallAdderWith("BETWEEN", Errors.BETWEEN)); |
brunodles/java-validation | src/test/java/com/github/brunodles/javavalidation/matcher/DoubleMatcherTest.java | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
| import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import com.mscharhag.oleaster.runner.OleasterRunner;
import org.junit.runner.RunWith;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.before;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.describe;
import static org.mockito.Mockito.mock; | package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 04/06/16.
*/
@RunWith(OleasterRunner.class)
public class DoubleMatcherTest extends NumberMatcherTestBase<Double, DoubleMatcher> {
{
describe("Given a IntegerMatcher for 7", () -> {
before(() -> { | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
// Path: src/test/java/com/github/brunodles/javavalidation/matcher/DoubleMatcherTest.java
import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import com.mscharhag.oleaster.runner.OleasterRunner;
import org.junit.runner.RunWith;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.before;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.describe;
import static org.mockito.Mockito.mock;
package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 04/06/16.
*/
@RunWith(OleasterRunner.class)
public class DoubleMatcherTest extends NumberMatcherTestBase<Double, DoubleMatcher> {
{
describe("Given a IntegerMatcher for 7", () -> {
before(() -> { | adder = mock(IntConsumer.class); |
brunodles/java-validation | src/test/java/com/github/brunodles/javavalidation/matcher/DoubleMatcherTest.java | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
| import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import com.mscharhag.oleaster.runner.OleasterRunner;
import org.junit.runner.RunWith;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.before;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.describe;
import static org.mockito.Mockito.mock; | package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 04/06/16.
*/
@RunWith(OleasterRunner.class)
public class DoubleMatcherTest extends NumberMatcherTestBase<Double, DoubleMatcher> {
{
describe("Given a IntegerMatcher for 7", () -> {
before(() -> {
adder = mock(IntConsumer.class);
matcher = new DoubleMatcher(7D, adder);
});
describe("when call isBetween", () -> {
when_isBetween(1D, 7D, this::itShouldNotCallAdder);
when_isBetween(7D, 10D, this::itShouldNotCallAdder); | // Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
// // Object
// public static final int NULL = 1;
// public static final int EQUAL = 2;
//
// // Boolean
// public static final int FALSE = 4;
// public static final int TRUE = 8;
//
// // String
// public static final int EMPTY = 16;
//
// // Integer
// public static final int GREATER = 32;
// public static final int LOWER = 64;
// public static final int BETWEEN = 128;
// }
//
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param value the input argument
// */
// void accept(int value);
//
// }
// Path: src/test/java/com/github/brunodles/javavalidation/matcher/DoubleMatcherTest.java
import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.IntConsumer;
import com.mscharhag.oleaster.runner.OleasterRunner;
import org.junit.runner.RunWith;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.before;
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.describe;
import static org.mockito.Mockito.mock;
package com.github.brunodles.javavalidation.matcher;
/**
* Created by bruno on 04/06/16.
*/
@RunWith(OleasterRunner.class)
public class DoubleMatcherTest extends NumberMatcherTestBase<Double, DoubleMatcher> {
{
describe("Given a IntegerMatcher for 7", () -> {
before(() -> {
adder = mock(IntConsumer.class);
matcher = new DoubleMatcher(7D, adder);
});
describe("when call isBetween", () -> {
when_isBetween(1D, 7D, this::itShouldNotCallAdder);
when_isBetween(7D, 10D, this::itShouldNotCallAdder); | when_isBetween(5D, 9D, () -> itShouldCallAdderWith("BETWEEN", Errors.BETWEEN)); |
curtbinder/AndroidStatus | app/src/main/java/info/curtbinder/reefangel/phone/ErrorListCursorAdapter.java | // Path: app/src/main/java/info/curtbinder/reefangel/db/ErrorTable.java
// public class ErrorTable {
//
// // private static final String TAG = ErrorTable.class.getSimpleName();
//
// // Database constants
// public static final String TABLE_NAME = "errors";
// // columns
// public static final String COL_ID = "_id";
// public static final String COL_TIME = "time";
// public static final String COL_MESSAGE = "message";
// public static final String COL_READ = "read";
//
// private static final String CREATE_TABLE =
// "CREATE TABLE IF NOT EXISTS " + TABLE_NAME + " (" + COL_ID
// + " INTEGER PRIMARY KEY AUTOINCREMENT, " + COL_TIME
// + " INTEGER, " + COL_MESSAGE + " TEXT, " + COL_READ
// + " INTEGER);";
// private static final String DROP_TABLE = "DROP TABLE IF EXISTS "
// + TABLE_NAME;
//
// public static void onCreate ( SQLiteDatabase db ) {
// db.execSQL( CREATE_TABLE );
// }
//
// public static void onUpgrade (
// SQLiteDatabase db,
// int oldVersion,
// int newVersion ) {
// int curVer = oldVersion;
// while ( curVer < newVersion ) {
// curVer++;
// switch ( curVer ) {
// default:
// break;
// case 5:
// upgradeToVersion5(db);
// break;
// }
// }
// }
//
// private static void upgradeToVersion5 ( SQLiteDatabase db ) {
// // table did not exist prior to version 5
// dropTable(db);
// onCreate(db);
// }
//
// private static void dropTable ( SQLiteDatabase db ) {
// db.execSQL( DROP_TABLE );
// }
//
// public static void onDowngrade (
// SQLiteDatabase db,
// int oldVersion,
// int newVersion ) {
// int curVer = oldVersion;
// while ( curVer > newVersion ) {
// curVer--;
// switch ( curVer ) {
// default:
// break;
// case 4:
// case 3:
// case 2:
// case 1:
// // drop the table if the downgraded version is less than 5
// dropTable(db);
// break;
// }
// }
// }
// }
| import android.widget.TextView;
import info.curtbinder.reefangel.db.ErrorTable;
import android.content.Context;
import android.database.Cursor;
import android.support.v4.widget.CursorAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 Curt Binder
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package info.curtbinder.reefangel.phone;
public class ErrorListCursorAdapter extends CursorAdapter {
static class ViewHolder {
TextView date;
TextView msg;
}
public ErrorListCursorAdapter ( Context context, Cursor c, int flags ) {
super( context, c, flags );
}
@Override
public void bindView ( View view, Context context, Cursor cursor ) {
final ViewHolder vh = (ViewHolder) view.getTag();
setViews( vh, cursor );
}
@Override
public View newView ( Context context, Cursor cursor, ViewGroup parent ) {
final LayoutInflater inflater = LayoutInflater.from( context );
View v = inflater.inflate( R.layout.frag_errors_item, parent, false );
ViewHolder vh = new ViewHolder();
vh.date = (TextView) v.findViewById( R.id.error_date );
vh.msg = (TextView) v.findViewById( R.id.error_message );
setViews( vh, cursor );
v.setTag( vh );
return v;
}
private void setViews ( ViewHolder v, Cursor c ) { | // Path: app/src/main/java/info/curtbinder/reefangel/db/ErrorTable.java
// public class ErrorTable {
//
// // private static final String TAG = ErrorTable.class.getSimpleName();
//
// // Database constants
// public static final String TABLE_NAME = "errors";
// // columns
// public static final String COL_ID = "_id";
// public static final String COL_TIME = "time";
// public static final String COL_MESSAGE = "message";
// public static final String COL_READ = "read";
//
// private static final String CREATE_TABLE =
// "CREATE TABLE IF NOT EXISTS " + TABLE_NAME + " (" + COL_ID
// + " INTEGER PRIMARY KEY AUTOINCREMENT, " + COL_TIME
// + " INTEGER, " + COL_MESSAGE + " TEXT, " + COL_READ
// + " INTEGER);";
// private static final String DROP_TABLE = "DROP TABLE IF EXISTS "
// + TABLE_NAME;
//
// public static void onCreate ( SQLiteDatabase db ) {
// db.execSQL( CREATE_TABLE );
// }
//
// public static void onUpgrade (
// SQLiteDatabase db,
// int oldVersion,
// int newVersion ) {
// int curVer = oldVersion;
// while ( curVer < newVersion ) {
// curVer++;
// switch ( curVer ) {
// default:
// break;
// case 5:
// upgradeToVersion5(db);
// break;
// }
// }
// }
//
// private static void upgradeToVersion5 ( SQLiteDatabase db ) {
// // table did not exist prior to version 5
// dropTable(db);
// onCreate(db);
// }
//
// private static void dropTable ( SQLiteDatabase db ) {
// db.execSQL( DROP_TABLE );
// }
//
// public static void onDowngrade (
// SQLiteDatabase db,
// int oldVersion,
// int newVersion ) {
// int curVer = oldVersion;
// while ( curVer > newVersion ) {
// curVer--;
// switch ( curVer ) {
// default:
// break;
// case 4:
// case 3:
// case 2:
// case 1:
// // drop the table if the downgraded version is less than 5
// dropTable(db);
// break;
// }
// }
// }
// }
// Path: app/src/main/java/info/curtbinder/reefangel/phone/ErrorListCursorAdapter.java
import android.widget.TextView;
import info.curtbinder.reefangel.db.ErrorTable;
import android.content.Context;
import android.database.Cursor;
import android.support.v4.widget.CursorAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 Curt Binder
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package info.curtbinder.reefangel.phone;
public class ErrorListCursorAdapter extends CursorAdapter {
static class ViewHolder {
TextView date;
TextView msg;
}
public ErrorListCursorAdapter ( Context context, Cursor c, int flags ) {
super( context, c, flags );
}
@Override
public void bindView ( View view, Context context, Cursor cursor ) {
final ViewHolder vh = (ViewHolder) view.getTag();
setViews( vh, cursor );
}
@Override
public View newView ( Context context, Cursor cursor, ViewGroup parent ) {
final LayoutInflater inflater = LayoutInflater.from( context );
View v = inflater.inflate( R.layout.frag_errors_item, parent, false );
ViewHolder vh = new ViewHolder();
vh.date = (TextView) v.findViewById( R.id.error_date );
vh.msg = (TextView) v.findViewById( R.id.error_message );
setViews( vh, cursor );
v.setTag( vh );
return v;
}
private void setViews ( ViewHolder v, Cursor c ) { | v.msg.setText( c.getString( c.getColumnIndex( ErrorTable.COL_MESSAGE ) ) ); |
curtbinder/AndroidStatus | app/src/main/java/info/curtbinder/reefangel/phone/DialogAddUserMemoryLocation.java | // Path: app/src/main/java/info/curtbinder/reefangel/db/UserMemoryLocationsTable.java
// public class UserMemoryLocationsTable {
//
// public static final String TABLE_NAME = "usermemorylocations";
// // columns
// public static final String COL_ID = "_id";
// public static final String COL_NAME = "name";
// public static final String COL_LOCATION = "location";
// public static final String COL_TYPE = "type";
// public static final String COL_SORT_ORDER = "sortorder";
//
// public static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS " + TABLE_NAME
// + " (" + COL_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
// + COL_NAME + " TEXT, " + COL_LOCATION + " INTEGER, "
// + COL_TYPE + " INTEGER DEFAULT 0, "
// + COL_SORT_ORDER + " INTEGER);";
//
// private static final String DROP_TABLE = "DROP TABLE IF EXISTS "
// + TABLE_NAME;
//
// public static void onCreate (SQLiteDatabase db) { db.execSQL(CREATE_TABLE); }
//
// public static void onUpgrade (
// SQLiteDatabase db,
// int oldVersion,
// int newVersion ) {
// int curVer = oldVersion;
// while (curVer < newVersion) {
// curVer++;
// if ( curVer == 15 ) {
// upgradeToVersion15(db);
// }
// }
// }
//
// public static void upgradeToVersion15 (SQLiteDatabase db) {
// onCreate(db);
// }
//
// private static void dropTable (SQLiteDatabase db) { db.execSQL(DROP_TABLE); }
//
// public static void onDowngrade (
// SQLiteDatabase db,
// int oldVersion,
// int newVersion ) {
// int curVer = oldVersion;
// while ( curVer > newVersion ) {
// curVer--;
// if (curVer < 15) {
// // drop the table if downgrade is less than 15 (version table was added)
// dropTable(db);
// break;
// }
// }
// }
// }
//
// Path: app/src/main/java/info/curtbinder/reefangel/phone/MemoryFragment.java
// public static final int CONFIRM_DELETE = 2;
| import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import android.support.v7.view.ContextThemeWrapper;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.Toast;
import info.curtbinder.reefangel.db.UserMemoryLocationsTable;
import static info.curtbinder.reefangel.phone.MemoryFragment.TabUserFrag.CONFIRM_DELETE;
import android.app.Activity;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull; | /*
* The MIT License (MIT)
*
* Copyright (c) 2019 Curt Binder
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package info.curtbinder.reefangel.phone;
public class DialogAddUserMemoryLocation extends DialogFragment {
private static final String TAG = DialogAddUserMemoryLocation.class.getSimpleName();
private EditText name;
private EditText location;
private RadioButton intButton;
private RadioButton byteButton;
private long id;
public DialogAddUserMemoryLocation() {
}
public static DialogAddUserMemoryLocation newInstance() {
return new DialogAddUserMemoryLocation();
}
public static DialogAddUserMemoryLocation newInstance(MemoryFragment.TabUserFrag.MemoryData memoryData) {
DialogAddUserMemoryLocation d = DialogAddUserMemoryLocation.newInstance();
Bundle args = new Bundle(); | // Path: app/src/main/java/info/curtbinder/reefangel/db/UserMemoryLocationsTable.java
// public class UserMemoryLocationsTable {
//
// public static final String TABLE_NAME = "usermemorylocations";
// // columns
// public static final String COL_ID = "_id";
// public static final String COL_NAME = "name";
// public static final String COL_LOCATION = "location";
// public static final String COL_TYPE = "type";
// public static final String COL_SORT_ORDER = "sortorder";
//
// public static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS " + TABLE_NAME
// + " (" + COL_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
// + COL_NAME + " TEXT, " + COL_LOCATION + " INTEGER, "
// + COL_TYPE + " INTEGER DEFAULT 0, "
// + COL_SORT_ORDER + " INTEGER);";
//
// private static final String DROP_TABLE = "DROP TABLE IF EXISTS "
// + TABLE_NAME;
//
// public static void onCreate (SQLiteDatabase db) { db.execSQL(CREATE_TABLE); }
//
// public static void onUpgrade (
// SQLiteDatabase db,
// int oldVersion,
// int newVersion ) {
// int curVer = oldVersion;
// while (curVer < newVersion) {
// curVer++;
// if ( curVer == 15 ) {
// upgradeToVersion15(db);
// }
// }
// }
//
// public static void upgradeToVersion15 (SQLiteDatabase db) {
// onCreate(db);
// }
//
// private static void dropTable (SQLiteDatabase db) { db.execSQL(DROP_TABLE); }
//
// public static void onDowngrade (
// SQLiteDatabase db,
// int oldVersion,
// int newVersion ) {
// int curVer = oldVersion;
// while ( curVer > newVersion ) {
// curVer--;
// if (curVer < 15) {
// // drop the table if downgrade is less than 15 (version table was added)
// dropTable(db);
// break;
// }
// }
// }
// }
//
// Path: app/src/main/java/info/curtbinder/reefangel/phone/MemoryFragment.java
// public static final int CONFIRM_DELETE = 2;
// Path: app/src/main/java/info/curtbinder/reefangel/phone/DialogAddUserMemoryLocation.java
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import android.support.v7.view.ContextThemeWrapper;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.Toast;
import info.curtbinder.reefangel.db.UserMemoryLocationsTable;
import static info.curtbinder.reefangel.phone.MemoryFragment.TabUserFrag.CONFIRM_DELETE;
import android.app.Activity;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Curt Binder
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package info.curtbinder.reefangel.phone;
public class DialogAddUserMemoryLocation extends DialogFragment {
private static final String TAG = DialogAddUserMemoryLocation.class.getSimpleName();
private EditText name;
private EditText location;
private RadioButton intButton;
private RadioButton byteButton;
private long id;
public DialogAddUserMemoryLocation() {
}
public static DialogAddUserMemoryLocation newInstance() {
return new DialogAddUserMemoryLocation();
}
public static DialogAddUserMemoryLocation newInstance(MemoryFragment.TabUserFrag.MemoryData memoryData) {
DialogAddUserMemoryLocation d = DialogAddUserMemoryLocation.newInstance();
Bundle args = new Bundle(); | args.putLong(UserMemoryLocationsTable.COL_ID, memoryData.id); |
curtbinder/AndroidStatus | app/src/main/java/info/curtbinder/reefangel/phone/DialogAddUserMemoryLocation.java | // Path: app/src/main/java/info/curtbinder/reefangel/db/UserMemoryLocationsTable.java
// public class UserMemoryLocationsTable {
//
// public static final String TABLE_NAME = "usermemorylocations";
// // columns
// public static final String COL_ID = "_id";
// public static final String COL_NAME = "name";
// public static final String COL_LOCATION = "location";
// public static final String COL_TYPE = "type";
// public static final String COL_SORT_ORDER = "sortorder";
//
// public static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS " + TABLE_NAME
// + " (" + COL_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
// + COL_NAME + " TEXT, " + COL_LOCATION + " INTEGER, "
// + COL_TYPE + " INTEGER DEFAULT 0, "
// + COL_SORT_ORDER + " INTEGER);";
//
// private static final String DROP_TABLE = "DROP TABLE IF EXISTS "
// + TABLE_NAME;
//
// public static void onCreate (SQLiteDatabase db) { db.execSQL(CREATE_TABLE); }
//
// public static void onUpgrade (
// SQLiteDatabase db,
// int oldVersion,
// int newVersion ) {
// int curVer = oldVersion;
// while (curVer < newVersion) {
// curVer++;
// if ( curVer == 15 ) {
// upgradeToVersion15(db);
// }
// }
// }
//
// public static void upgradeToVersion15 (SQLiteDatabase db) {
// onCreate(db);
// }
//
// private static void dropTable (SQLiteDatabase db) { db.execSQL(DROP_TABLE); }
//
// public static void onDowngrade (
// SQLiteDatabase db,
// int oldVersion,
// int newVersion ) {
// int curVer = oldVersion;
// while ( curVer > newVersion ) {
// curVer--;
// if (curVer < 15) {
// // drop the table if downgrade is less than 15 (version table was added)
// dropTable(db);
// break;
// }
// }
// }
// }
//
// Path: app/src/main/java/info/curtbinder/reefangel/phone/MemoryFragment.java
// public static final int CONFIRM_DELETE = 2;
| import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import android.support.v7.view.ContextThemeWrapper;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.Toast;
import info.curtbinder.reefangel.db.UserMemoryLocationsTable;
import static info.curtbinder.reefangel.phone.MemoryFragment.TabUserFrag.CONFIRM_DELETE;
import android.app.Activity;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull; | findViews(root);
Bundle args = getArguments();
if (args != null) {
loadData(args);
} else {
id = -1;
}
builder.setView(root);
builder.setPositiveButton(R.string.buttonSave, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if ( ! canSave() ) {
return;
}
Intent intent = saveUserMemoryLocation();
getTargetFragment().onActivityResult(getTargetRequestCode(), Activity.RESULT_OK, intent);
}
});
if (isUpdate()) {
// TODO change hardcoded update title to use a string resource
builder.setTitle("Update Location");
builder.setNegativeButton(R.string.buttonDelete, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Intent intent = new Intent();
Bundle extras = new Bundle();
extras.putLong(UserMemoryLocationsTable.COL_ID, id);
intent.putExtras(extras);
getTargetFragment().onActivityResult(getTargetRequestCode(), | // Path: app/src/main/java/info/curtbinder/reefangel/db/UserMemoryLocationsTable.java
// public class UserMemoryLocationsTable {
//
// public static final String TABLE_NAME = "usermemorylocations";
// // columns
// public static final String COL_ID = "_id";
// public static final String COL_NAME = "name";
// public static final String COL_LOCATION = "location";
// public static final String COL_TYPE = "type";
// public static final String COL_SORT_ORDER = "sortorder";
//
// public static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS " + TABLE_NAME
// + " (" + COL_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
// + COL_NAME + " TEXT, " + COL_LOCATION + " INTEGER, "
// + COL_TYPE + " INTEGER DEFAULT 0, "
// + COL_SORT_ORDER + " INTEGER);";
//
// private static final String DROP_TABLE = "DROP TABLE IF EXISTS "
// + TABLE_NAME;
//
// public static void onCreate (SQLiteDatabase db) { db.execSQL(CREATE_TABLE); }
//
// public static void onUpgrade (
// SQLiteDatabase db,
// int oldVersion,
// int newVersion ) {
// int curVer = oldVersion;
// while (curVer < newVersion) {
// curVer++;
// if ( curVer == 15 ) {
// upgradeToVersion15(db);
// }
// }
// }
//
// public static void upgradeToVersion15 (SQLiteDatabase db) {
// onCreate(db);
// }
//
// private static void dropTable (SQLiteDatabase db) { db.execSQL(DROP_TABLE); }
//
// public static void onDowngrade (
// SQLiteDatabase db,
// int oldVersion,
// int newVersion ) {
// int curVer = oldVersion;
// while ( curVer > newVersion ) {
// curVer--;
// if (curVer < 15) {
// // drop the table if downgrade is less than 15 (version table was added)
// dropTable(db);
// break;
// }
// }
// }
// }
//
// Path: app/src/main/java/info/curtbinder/reefangel/phone/MemoryFragment.java
// public static final int CONFIRM_DELETE = 2;
// Path: app/src/main/java/info/curtbinder/reefangel/phone/DialogAddUserMemoryLocation.java
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import android.support.v7.view.ContextThemeWrapper;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.Toast;
import info.curtbinder.reefangel.db.UserMemoryLocationsTable;
import static info.curtbinder.reefangel.phone.MemoryFragment.TabUserFrag.CONFIRM_DELETE;
import android.app.Activity;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
findViews(root);
Bundle args = getArguments();
if (args != null) {
loadData(args);
} else {
id = -1;
}
builder.setView(root);
builder.setPositiveButton(R.string.buttonSave, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if ( ! canSave() ) {
return;
}
Intent intent = saveUserMemoryLocation();
getTargetFragment().onActivityResult(getTargetRequestCode(), Activity.RESULT_OK, intent);
}
});
if (isUpdate()) {
// TODO change hardcoded update title to use a string resource
builder.setTitle("Update Location");
builder.setNegativeButton(R.string.buttonDelete, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Intent intent = new Intent();
Bundle extras = new Bundle();
extras.putLong(UserMemoryLocationsTable.COL_ID, id);
intent.putExtras(extras);
getTargetFragment().onActivityResult(getTargetRequestCode(), | CONFIRM_DELETE, intent); |
curtbinder/AndroidStatus | app/src/main/java/info/curtbinder/reefangel/phone/NotificationListCursorAdapter.java | // Path: app/src/main/java/info/curtbinder/reefangel/db/NotificationTable.java
// public class NotificationTable {
// // Database constants
// public static final String TABLE_NAME = "notifications";
// // columns
// public static final String COL_ID = "_id";
// public static final String COL_PARAM = "param";
// public static final String COL_CONDITION = "condition";
// public static final String COL_VALUE = "value";
//
// private static final String CREATE_TABLE =
// "CREATE TABLE IF NOT EXISTS " + TABLE_NAME + " (" + COL_ID
// + " INTEGER PRIMARY KEY AUTOINCREMENT, " + COL_PARAM
// + " INTEGER, " + COL_CONDITION + " INTEGER, " + COL_VALUE
// + " TEXT);";
// private static final String DROP_TABLE = "DROP TABLE IF EXISTS "
// + TABLE_NAME;
//
// public static void onCreate ( SQLiteDatabase db ) {
// db.execSQL( CREATE_TABLE );
// }
//
// public static void onUpgrade (
// SQLiteDatabase db,
// int oldVersion,
// int newVersion ) {
// int curVer = oldVersion;
// while ( curVer < newVersion ) {
// curVer++;
// switch (curVer) {
// default:
// break;
// case 6:
// upgradeToVersion6(db);
// break;
// }
// }
// }
//
// private static void upgradeToVersion6 ( SQLiteDatabase db ) {
// // table did no exist prior to version 6, so just drop it as a safety precaution
// // then create it
// dropTable(db);
// onCreate(db);
// }
//
// private static void dropTable ( SQLiteDatabase db ) {
// db.execSQL( DROP_TABLE );
// }
//
// public static void onDowngrade (
// SQLiteDatabase db,
// int oldVersion,
// int newVersion ) {
// int curVer = oldVersion;
// while ( curVer > newVersion ) {
// curVer--;
// switch ( curVer ) {
// default:
// break;
// case 5:
// case 4:
// case 3:
// case 2:
// case 1:
// // drop the table if the downgraded version is less than 6
// dropTable(db);
// break;
// }
// }
// }
// }
| import android.view.ViewGroup;
import android.widget.TextView;
import java.util.Locale;
import info.curtbinder.reefangel.db.NotificationTable;
import android.content.Context;
import android.content.res.Resources;
import android.database.Cursor;
import android.support.v4.widget.CursorAdapter;
import android.view.LayoutInflater;
import android.view.View; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 Curt Binder
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package info.curtbinder.reefangel.phone;
/**
* Created by binder on 3/23/14.
*/
public class NotificationListCursorAdapter extends CursorAdapter {
static private String[] deviceParameters;
static private String[] notifyConditions;
private final int LAYOUT = R.layout.frag_notification_item;
public NotificationListCursorAdapter(Context context, Cursor c, int flags) {
super(context, c, flags);
final Resources r = context.getResources();
deviceParameters = r.getStringArray(R.array.deviceParameters);
notifyConditions = r.getStringArray(R.array.notifyConditions);
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
final ViewHolder vh = (ViewHolder) view.getTag();
setViews(vh, cursor);
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
final LayoutInflater inflater = LayoutInflater.from(context);
View v = inflater.inflate(LAYOUT, parent, false);
ViewHolder vh = new ViewHolder();
vh.item = (TextView) v.findViewById(R.id.notification_item);
setViews(vh, cursor);
v.setTag(vh);
return v;
}
private void setViews(ViewHolder v, Cursor c) { | // Path: app/src/main/java/info/curtbinder/reefangel/db/NotificationTable.java
// public class NotificationTable {
// // Database constants
// public static final String TABLE_NAME = "notifications";
// // columns
// public static final String COL_ID = "_id";
// public static final String COL_PARAM = "param";
// public static final String COL_CONDITION = "condition";
// public static final String COL_VALUE = "value";
//
// private static final String CREATE_TABLE =
// "CREATE TABLE IF NOT EXISTS " + TABLE_NAME + " (" + COL_ID
// + " INTEGER PRIMARY KEY AUTOINCREMENT, " + COL_PARAM
// + " INTEGER, " + COL_CONDITION + " INTEGER, " + COL_VALUE
// + " TEXT);";
// private static final String DROP_TABLE = "DROP TABLE IF EXISTS "
// + TABLE_NAME;
//
// public static void onCreate ( SQLiteDatabase db ) {
// db.execSQL( CREATE_TABLE );
// }
//
// public static void onUpgrade (
// SQLiteDatabase db,
// int oldVersion,
// int newVersion ) {
// int curVer = oldVersion;
// while ( curVer < newVersion ) {
// curVer++;
// switch (curVer) {
// default:
// break;
// case 6:
// upgradeToVersion6(db);
// break;
// }
// }
// }
//
// private static void upgradeToVersion6 ( SQLiteDatabase db ) {
// // table did no exist prior to version 6, so just drop it as a safety precaution
// // then create it
// dropTable(db);
// onCreate(db);
// }
//
// private static void dropTable ( SQLiteDatabase db ) {
// db.execSQL( DROP_TABLE );
// }
//
// public static void onDowngrade (
// SQLiteDatabase db,
// int oldVersion,
// int newVersion ) {
// int curVer = oldVersion;
// while ( curVer > newVersion ) {
// curVer--;
// switch ( curVer ) {
// default:
// break;
// case 5:
// case 4:
// case 3:
// case 2:
// case 1:
// // drop the table if the downgraded version is less than 6
// dropTable(db);
// break;
// }
// }
// }
// }
// Path: app/src/main/java/info/curtbinder/reefangel/phone/NotificationListCursorAdapter.java
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.Locale;
import info.curtbinder.reefangel.db.NotificationTable;
import android.content.Context;
import android.content.res.Resources;
import android.database.Cursor;
import android.support.v4.widget.CursorAdapter;
import android.view.LayoutInflater;
import android.view.View;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 Curt Binder
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package info.curtbinder.reefangel.phone;
/**
* Created by binder on 3/23/14.
*/
public class NotificationListCursorAdapter extends CursorAdapter {
static private String[] deviceParameters;
static private String[] notifyConditions;
private final int LAYOUT = R.layout.frag_notification_item;
public NotificationListCursorAdapter(Context context, Cursor c, int flags) {
super(context, c, flags);
final Resources r = context.getResources();
deviceParameters = r.getStringArray(R.array.deviceParameters);
notifyConditions = r.getStringArray(R.array.notifyConditions);
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
final ViewHolder vh = (ViewHolder) view.getTag();
setViews(vh, cursor);
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
final LayoutInflater inflater = LayoutInflater.from(context);
View v = inflater.inflate(LAYOUT, parent, false);
ViewHolder vh = new ViewHolder();
vh.item = (TextView) v.findViewById(R.id.notification_item);
setViews(vh, cursor);
v.setTag(vh);
return v;
}
private void setViews(ViewHolder v, Cursor c) { | int param = c.getInt(c.getColumnIndex(NotificationTable.COL_PARAM)); |
curtbinder/AndroidStatus | app/src/main/java/info/curtbinder/reefangel/controller/DateTime.java | // Path: app/src/main/java/info/curtbinder/reefangel/phone/Utils.java
// public class Utils {
//
// public final static int THEME_DARK = 0;
// public final static int THEME_LIGHT = 1;
// private static int iTheme = THEME_LIGHT;
//
// public static int getCurrentTheme() { return iTheme; }
//
// /**
// * Set the theme of the Activity, and restart it by creating a new Activity of the same type.
// */
// public static void changeToTheme(Activity activity, int theme)
// {
// iTheme = theme;
// activity.finish();
// activity.startActivity(new Intent(activity, activity.getClass()));
// }
// /** Set the theme of the activity, according to the configuration. */
// public static void onActivityCreateSetTheme(Activity activity)
// {
// switch (iTheme)
// {
// default:
// case THEME_LIGHT:
// activity.setTheme(R.style.AppTheme);
// break;
// case THEME_DARK:
// // activity.setTheme(R.style.AppThemeDark);
// break;
// }
// }
// public static void onActivityCreateSetTheme(Activity activity, int theme) {
// iTheme = theme;
// onActivityCreateSetTheme(activity);
// }
//
// public static SimpleDateFormat getDefaultDateFormat() {
// return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
// }
//
// public static String getNotificationDateFormatString(long when) {
// DateFormat fmt = Utils.getNotificationDateFormat();
// return fmt.format(new Date(when));
// }
//
// private static DateFormat getNotificationDateFormat() {
// return DateFormat.getDateTimeInstance(DateFormat.SHORT,
// DateFormat.SHORT,
// Locale.getDefault());
// }
//
// public static DateFormat getOldDefaultDateFormat() {
// return DateFormat.getDateTimeInstance( DateFormat.DEFAULT,
// DateFormat.DEFAULT,
// Locale.getDefault() );
// }
//
// public static String getDisplayDate(String dbDateFormat) {
// // Assign the return value to be the date given
// // If there is a problem converting the date, just return the given date
// String displayDate = dbDateFormat;
// SimpleDateFormat dftProper = Utils.getDefaultDateFormat();
// Date d;
// try {
// // Parse the universal standard date format that is stored in the DB
// d = dftProper.parse(dbDateFormat);
// Calendar cal = Calendar.getInstance();
// cal.setTime(d);
// DateFormat dftDisplay = Utils.getOldDefaultDateFormat();
// // Convert to the display date format
// displayDate = dftDisplay.format(cal.getTime());
// } catch (ParseException e) {
// e.printStackTrace();
// }
// return displayDate;
// }
// }
//
// Path: app/src/main/java/info/curtbinder/reefangel/service/RequestCommands.java
// public final class RequestCommands {
// // Request commands sent to the controller
// public static final String MemoryByte = "/mb";
// public static final String MemoryInt = "/mi";
// public static final String Status = "/r99";
// // public static final String Status = "/sr";
// public static final String DateTime = "/d";
// public static final String Version = "/v";
// public static final String FeedingMode = "/mf";
// public static final String WaterMode = "/mw";
// public static final String AtoClear = "/mt";
// public static final String OverheatClear = "/mo";
// public static final String ExitMode = "/bp";
// public static final String Relay = "/r";
// public static final String LightsOn = "/l1";
// public static final String LightsOff = "/l0";
// public static final String Reboot = "/boot";
// public static final String Calibrate = "/cal";
// public static final String PwmOverride = "/po";
// public static final String CustomVar = "/cvar";
// public static final String None = "";
// public static final String ReefAngel = "ra";
// }
| import info.curtbinder.reefangel.phone.Utils;
import info.curtbinder.reefangel.service.RequestCommands;
import java.text.DateFormat;
import java.util.Calendar;
import java.util.Locale; | this.updateStatus = s;
}
public String getUpdateStatus ( ) {
return updateStatus;
}
public String getDateString ( ) {
// TODO confirm proper month formatting
DateFormat dft =
DateFormat.getDateInstance( DateFormat.SHORT,
Locale.getDefault() );
Calendar c = Calendar.getInstance();
c.clear();
c.set( year, month, day );
return dft.format( c.getTime() );
}
public String getTimeString ( ) {
DateFormat dft =
DateFormat.getTimeInstance( DateFormat.SHORT,
Locale.getDefault() );
Calendar c = Calendar.getInstance();
c.clear();
c.set( 0, Calendar.JANUARY, 0, hour, minute );
return dft.format( c.getTime() );
}
public String getDateTimeString ( ) {
// TODO confirm usage of getDateTimeString function call | // Path: app/src/main/java/info/curtbinder/reefangel/phone/Utils.java
// public class Utils {
//
// public final static int THEME_DARK = 0;
// public final static int THEME_LIGHT = 1;
// private static int iTheme = THEME_LIGHT;
//
// public static int getCurrentTheme() { return iTheme; }
//
// /**
// * Set the theme of the Activity, and restart it by creating a new Activity of the same type.
// */
// public static void changeToTheme(Activity activity, int theme)
// {
// iTheme = theme;
// activity.finish();
// activity.startActivity(new Intent(activity, activity.getClass()));
// }
// /** Set the theme of the activity, according to the configuration. */
// public static void onActivityCreateSetTheme(Activity activity)
// {
// switch (iTheme)
// {
// default:
// case THEME_LIGHT:
// activity.setTheme(R.style.AppTheme);
// break;
// case THEME_DARK:
// // activity.setTheme(R.style.AppThemeDark);
// break;
// }
// }
// public static void onActivityCreateSetTheme(Activity activity, int theme) {
// iTheme = theme;
// onActivityCreateSetTheme(activity);
// }
//
// public static SimpleDateFormat getDefaultDateFormat() {
// return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
// }
//
// public static String getNotificationDateFormatString(long when) {
// DateFormat fmt = Utils.getNotificationDateFormat();
// return fmt.format(new Date(when));
// }
//
// private static DateFormat getNotificationDateFormat() {
// return DateFormat.getDateTimeInstance(DateFormat.SHORT,
// DateFormat.SHORT,
// Locale.getDefault());
// }
//
// public static DateFormat getOldDefaultDateFormat() {
// return DateFormat.getDateTimeInstance( DateFormat.DEFAULT,
// DateFormat.DEFAULT,
// Locale.getDefault() );
// }
//
// public static String getDisplayDate(String dbDateFormat) {
// // Assign the return value to be the date given
// // If there is a problem converting the date, just return the given date
// String displayDate = dbDateFormat;
// SimpleDateFormat dftProper = Utils.getDefaultDateFormat();
// Date d;
// try {
// // Parse the universal standard date format that is stored in the DB
// d = dftProper.parse(dbDateFormat);
// Calendar cal = Calendar.getInstance();
// cal.setTime(d);
// DateFormat dftDisplay = Utils.getOldDefaultDateFormat();
// // Convert to the display date format
// displayDate = dftDisplay.format(cal.getTime());
// } catch (ParseException e) {
// e.printStackTrace();
// }
// return displayDate;
// }
// }
//
// Path: app/src/main/java/info/curtbinder/reefangel/service/RequestCommands.java
// public final class RequestCommands {
// // Request commands sent to the controller
// public static final String MemoryByte = "/mb";
// public static final String MemoryInt = "/mi";
// public static final String Status = "/r99";
// // public static final String Status = "/sr";
// public static final String DateTime = "/d";
// public static final String Version = "/v";
// public static final String FeedingMode = "/mf";
// public static final String WaterMode = "/mw";
// public static final String AtoClear = "/mt";
// public static final String OverheatClear = "/mo";
// public static final String ExitMode = "/bp";
// public static final String Relay = "/r";
// public static final String LightsOn = "/l1";
// public static final String LightsOff = "/l0";
// public static final String Reboot = "/boot";
// public static final String Calibrate = "/cal";
// public static final String PwmOverride = "/po";
// public static final String CustomVar = "/cvar";
// public static final String None = "";
// public static final String ReefAngel = "ra";
// }
// Path: app/src/main/java/info/curtbinder/reefangel/controller/DateTime.java
import info.curtbinder.reefangel.phone.Utils;
import info.curtbinder.reefangel.service.RequestCommands;
import java.text.DateFormat;
import java.util.Calendar;
import java.util.Locale;
this.updateStatus = s;
}
public String getUpdateStatus ( ) {
return updateStatus;
}
public String getDateString ( ) {
// TODO confirm proper month formatting
DateFormat dft =
DateFormat.getDateInstance( DateFormat.SHORT,
Locale.getDefault() );
Calendar c = Calendar.getInstance();
c.clear();
c.set( year, month, day );
return dft.format( c.getTime() );
}
public String getTimeString ( ) {
DateFormat dft =
DateFormat.getTimeInstance( DateFormat.SHORT,
Locale.getDefault() );
Calendar c = Calendar.getInstance();
c.clear();
c.set( 0, Calendar.JANUARY, 0, hour, minute );
return dft.format( c.getTime() );
}
public String getDateTimeString ( ) {
// TODO confirm usage of getDateTimeString function call | DateFormat dft = Utils.getOldDefaultDateFormat(); |
curtbinder/AndroidStatus | app/src/main/java/info/curtbinder/reefangel/controller/DateTime.java | // Path: app/src/main/java/info/curtbinder/reefangel/phone/Utils.java
// public class Utils {
//
// public final static int THEME_DARK = 0;
// public final static int THEME_LIGHT = 1;
// private static int iTheme = THEME_LIGHT;
//
// public static int getCurrentTheme() { return iTheme; }
//
// /**
// * Set the theme of the Activity, and restart it by creating a new Activity of the same type.
// */
// public static void changeToTheme(Activity activity, int theme)
// {
// iTheme = theme;
// activity.finish();
// activity.startActivity(new Intent(activity, activity.getClass()));
// }
// /** Set the theme of the activity, according to the configuration. */
// public static void onActivityCreateSetTheme(Activity activity)
// {
// switch (iTheme)
// {
// default:
// case THEME_LIGHT:
// activity.setTheme(R.style.AppTheme);
// break;
// case THEME_DARK:
// // activity.setTheme(R.style.AppThemeDark);
// break;
// }
// }
// public static void onActivityCreateSetTheme(Activity activity, int theme) {
// iTheme = theme;
// onActivityCreateSetTheme(activity);
// }
//
// public static SimpleDateFormat getDefaultDateFormat() {
// return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
// }
//
// public static String getNotificationDateFormatString(long when) {
// DateFormat fmt = Utils.getNotificationDateFormat();
// return fmt.format(new Date(when));
// }
//
// private static DateFormat getNotificationDateFormat() {
// return DateFormat.getDateTimeInstance(DateFormat.SHORT,
// DateFormat.SHORT,
// Locale.getDefault());
// }
//
// public static DateFormat getOldDefaultDateFormat() {
// return DateFormat.getDateTimeInstance( DateFormat.DEFAULT,
// DateFormat.DEFAULT,
// Locale.getDefault() );
// }
//
// public static String getDisplayDate(String dbDateFormat) {
// // Assign the return value to be the date given
// // If there is a problem converting the date, just return the given date
// String displayDate = dbDateFormat;
// SimpleDateFormat dftProper = Utils.getDefaultDateFormat();
// Date d;
// try {
// // Parse the universal standard date format that is stored in the DB
// d = dftProper.parse(dbDateFormat);
// Calendar cal = Calendar.getInstance();
// cal.setTime(d);
// DateFormat dftDisplay = Utils.getOldDefaultDateFormat();
// // Convert to the display date format
// displayDate = dftDisplay.format(cal.getTime());
// } catch (ParseException e) {
// e.printStackTrace();
// }
// return displayDate;
// }
// }
//
// Path: app/src/main/java/info/curtbinder/reefangel/service/RequestCommands.java
// public final class RequestCommands {
// // Request commands sent to the controller
// public static final String MemoryByte = "/mb";
// public static final String MemoryInt = "/mi";
// public static final String Status = "/r99";
// // public static final String Status = "/sr";
// public static final String DateTime = "/d";
// public static final String Version = "/v";
// public static final String FeedingMode = "/mf";
// public static final String WaterMode = "/mw";
// public static final String AtoClear = "/mt";
// public static final String OverheatClear = "/mo";
// public static final String ExitMode = "/bp";
// public static final String Relay = "/r";
// public static final String LightsOn = "/l1";
// public static final String LightsOff = "/l0";
// public static final String Reboot = "/boot";
// public static final String Calibrate = "/cal";
// public static final String PwmOverride = "/po";
// public static final String CustomVar = "/cvar";
// public static final String None = "";
// public static final String ReefAngel = "ra";
// }
| import info.curtbinder.reefangel.phone.Utils;
import info.curtbinder.reefangel.service.RequestCommands;
import java.text.DateFormat;
import java.util.Calendar;
import java.util.Locale; | // TODO confirm usage of getDateTimeString function call
DateFormat dft = Utils.getOldDefaultDateFormat();
Calendar c = Calendar.getInstance();
c.clear();
c.set( year, month, day, hour, minute );
return dft.format( c.getTime() );
}
public void setWithCurrentDateTime ( ) {
Calendar now = Calendar.getInstance();
hour = now.get( Calendar.HOUR );
if ( now.get( Calendar.AM_PM ) == 1 ) {
hour += 12;
}
minute = now.get( Calendar.MINUTE );
month = now.get( Calendar.MONTH );
day = now.get( Calendar.DAY_OF_MONTH );
year = now.get( Calendar.YEAR );
}
public String getSetCommand ( ) {
return generateSetDateTimeCommand( hour, minute, month, day, year );
}
public static String generateSetDateTimeCommand (
int hr,
int min,
int mon,
int day,
int yr ) { | // Path: app/src/main/java/info/curtbinder/reefangel/phone/Utils.java
// public class Utils {
//
// public final static int THEME_DARK = 0;
// public final static int THEME_LIGHT = 1;
// private static int iTheme = THEME_LIGHT;
//
// public static int getCurrentTheme() { return iTheme; }
//
// /**
// * Set the theme of the Activity, and restart it by creating a new Activity of the same type.
// */
// public static void changeToTheme(Activity activity, int theme)
// {
// iTheme = theme;
// activity.finish();
// activity.startActivity(new Intent(activity, activity.getClass()));
// }
// /** Set the theme of the activity, according to the configuration. */
// public static void onActivityCreateSetTheme(Activity activity)
// {
// switch (iTheme)
// {
// default:
// case THEME_LIGHT:
// activity.setTheme(R.style.AppTheme);
// break;
// case THEME_DARK:
// // activity.setTheme(R.style.AppThemeDark);
// break;
// }
// }
// public static void onActivityCreateSetTheme(Activity activity, int theme) {
// iTheme = theme;
// onActivityCreateSetTheme(activity);
// }
//
// public static SimpleDateFormat getDefaultDateFormat() {
// return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
// }
//
// public static String getNotificationDateFormatString(long when) {
// DateFormat fmt = Utils.getNotificationDateFormat();
// return fmt.format(new Date(when));
// }
//
// private static DateFormat getNotificationDateFormat() {
// return DateFormat.getDateTimeInstance(DateFormat.SHORT,
// DateFormat.SHORT,
// Locale.getDefault());
// }
//
// public static DateFormat getOldDefaultDateFormat() {
// return DateFormat.getDateTimeInstance( DateFormat.DEFAULT,
// DateFormat.DEFAULT,
// Locale.getDefault() );
// }
//
// public static String getDisplayDate(String dbDateFormat) {
// // Assign the return value to be the date given
// // If there is a problem converting the date, just return the given date
// String displayDate = dbDateFormat;
// SimpleDateFormat dftProper = Utils.getDefaultDateFormat();
// Date d;
// try {
// // Parse the universal standard date format that is stored in the DB
// d = dftProper.parse(dbDateFormat);
// Calendar cal = Calendar.getInstance();
// cal.setTime(d);
// DateFormat dftDisplay = Utils.getOldDefaultDateFormat();
// // Convert to the display date format
// displayDate = dftDisplay.format(cal.getTime());
// } catch (ParseException e) {
// e.printStackTrace();
// }
// return displayDate;
// }
// }
//
// Path: app/src/main/java/info/curtbinder/reefangel/service/RequestCommands.java
// public final class RequestCommands {
// // Request commands sent to the controller
// public static final String MemoryByte = "/mb";
// public static final String MemoryInt = "/mi";
// public static final String Status = "/r99";
// // public static final String Status = "/sr";
// public static final String DateTime = "/d";
// public static final String Version = "/v";
// public static final String FeedingMode = "/mf";
// public static final String WaterMode = "/mw";
// public static final String AtoClear = "/mt";
// public static final String OverheatClear = "/mo";
// public static final String ExitMode = "/bp";
// public static final String Relay = "/r";
// public static final String LightsOn = "/l1";
// public static final String LightsOff = "/l0";
// public static final String Reboot = "/boot";
// public static final String Calibrate = "/cal";
// public static final String PwmOverride = "/po";
// public static final String CustomVar = "/cvar";
// public static final String None = "";
// public static final String ReefAngel = "ra";
// }
// Path: app/src/main/java/info/curtbinder/reefangel/controller/DateTime.java
import info.curtbinder.reefangel.phone.Utils;
import info.curtbinder.reefangel.service.RequestCommands;
import java.text.DateFormat;
import java.util.Calendar;
import java.util.Locale;
// TODO confirm usage of getDateTimeString function call
DateFormat dft = Utils.getOldDefaultDateFormat();
Calendar c = Calendar.getInstance();
c.clear();
c.set( year, month, day, hour, minute );
return dft.format( c.getTime() );
}
public void setWithCurrentDateTime ( ) {
Calendar now = Calendar.getInstance();
hour = now.get( Calendar.HOUR );
if ( now.get( Calendar.AM_PM ) == 1 ) {
hour += 12;
}
minute = now.get( Calendar.MINUTE );
month = now.get( Calendar.MONTH );
day = now.get( Calendar.DAY_OF_MONTH );
year = now.get( Calendar.YEAR );
}
public String getSetCommand ( ) {
return generateSetDateTimeCommand( hour, minute, month, day, year );
}
public static String generateSetDateTimeCommand (
int hr,
int min,
int mon,
int day,
int yr ) { | String cmd = RequestCommands.DateTime; |
OpsLabJPL/MarsImagesAndroid | MarsImages/MarsImages/src/main/java/gov/nasa/jpl/hi/marsimages/Utils.java | // Path: MarsImages/MarsImages/src/main/java/gov/nasa/jpl/hi/marsimages/ui/ImageViewActivity.java
// public class ImageViewActivity extends AppCompatActivity {
//
// private ImageViewPagerFragment imageViewPagerFragment;
//
// @Override
// public void onCreate(Bundle savedInstanceState) {
// // Utils.enableStrictMode();
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_image_view);
// int selectedPage = getIntent().getIntExtra(ImageViewPagerFragment.STATE_PAGE_NUMBER, 0);
// imageViewPagerFragment = (ImageViewPagerFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_image_view_pager);
// imageViewPagerFragment.setUpViewPager(selectedPage);
// }
//
// @Override
// public void onResume() {
// super.onResume();
// long pauseTimeMillis = MARS_IMAGES.getPauseTimestamp();
// ImageLoader.getInstance().resume();
// if (pauseTimeMillis > 0 && System.currentTimeMillis() - pauseTimeMillis > 30 * 60 * 1000)
// EVERNOTE.loadMoreImages(this, true);
// }
//
// @Override
// protected void onPause() {
// super.onPause();
// ImageLoader.getInstance().pause();
// MARS_IMAGES.setPauseTimestamp(System.currentTimeMillis());
// }
//
// @Override
// public void finish() {
// Intent data = getIntent();
// data.putExtra(ImageViewPagerFragment.STATE_PAGE_NUMBER, imageViewPagerFragment.getViewPager().getCurrentItem());
// setResult(RESULT_OK, data);
// super.finish();
// }
//
// @Override
// public boolean onCreateOptionsMenu(Menu menu) {
// // Inflate the menu; this adds items to the action bar if it is present.
// getMenuInflater().inflate(R.menu.image_view, menu);
// return super.onCreateOptionsMenu(menu);
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// final ImageViewPagerFragment imageViewPagerFragment = (ImageViewPagerFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_image_view_pager);
// switch (item.getItemId()) {
// case R.id.share:
// imageViewPagerFragment.shareImage();
// return true;
// case R.id.save:
// imageViewPagerFragment.saveImageToGallery();
// return true;
// }
// return super.onOptionsItemSelected(item);
// }
// }
| import android.annotation.TargetApi;
import android.os.Build;
import android.os.Build.VERSION_CODES;
import android.os.StrictMode;
import gov.nasa.jpl.hi.marsimages.ui.ImageViewActivity; | package gov.nasa.jpl.hi.marsimages;
/**
* Created by mpowell on 5/6/14.
*/
public class Utils {
private Utils() {
}
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static void enableStrictMode() {
if (Utils.hasGingerbread()) {
StrictMode.ThreadPolicy.Builder threadPolicyBuilder =
new StrictMode.ThreadPolicy.Builder()
.detectAll()
.penaltyLog();
StrictMode.VmPolicy.Builder vmPolicyBuilder =
new StrictMode.VmPolicy.Builder()
.detectAll()
.penaltyLog();
if (Utils.hasHoneycomb()) {
threadPolicyBuilder.penaltyFlashScreen();
vmPolicyBuilder | // Path: MarsImages/MarsImages/src/main/java/gov/nasa/jpl/hi/marsimages/ui/ImageViewActivity.java
// public class ImageViewActivity extends AppCompatActivity {
//
// private ImageViewPagerFragment imageViewPagerFragment;
//
// @Override
// public void onCreate(Bundle savedInstanceState) {
// // Utils.enableStrictMode();
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_image_view);
// int selectedPage = getIntent().getIntExtra(ImageViewPagerFragment.STATE_PAGE_NUMBER, 0);
// imageViewPagerFragment = (ImageViewPagerFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_image_view_pager);
// imageViewPagerFragment.setUpViewPager(selectedPage);
// }
//
// @Override
// public void onResume() {
// super.onResume();
// long pauseTimeMillis = MARS_IMAGES.getPauseTimestamp();
// ImageLoader.getInstance().resume();
// if (pauseTimeMillis > 0 && System.currentTimeMillis() - pauseTimeMillis > 30 * 60 * 1000)
// EVERNOTE.loadMoreImages(this, true);
// }
//
// @Override
// protected void onPause() {
// super.onPause();
// ImageLoader.getInstance().pause();
// MARS_IMAGES.setPauseTimestamp(System.currentTimeMillis());
// }
//
// @Override
// public void finish() {
// Intent data = getIntent();
// data.putExtra(ImageViewPagerFragment.STATE_PAGE_NUMBER, imageViewPagerFragment.getViewPager().getCurrentItem());
// setResult(RESULT_OK, data);
// super.finish();
// }
//
// @Override
// public boolean onCreateOptionsMenu(Menu menu) {
// // Inflate the menu; this adds items to the action bar if it is present.
// getMenuInflater().inflate(R.menu.image_view, menu);
// return super.onCreateOptionsMenu(menu);
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// final ImageViewPagerFragment imageViewPagerFragment = (ImageViewPagerFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_image_view_pager);
// switch (item.getItemId()) {
// case R.id.share:
// imageViewPagerFragment.shareImage();
// return true;
// case R.id.save:
// imageViewPagerFragment.saveImageToGallery();
// return true;
// }
// return super.onOptionsItemSelected(item);
// }
// }
// Path: MarsImages/MarsImages/src/main/java/gov/nasa/jpl/hi/marsimages/Utils.java
import android.annotation.TargetApi;
import android.os.Build;
import android.os.Build.VERSION_CODES;
import android.os.StrictMode;
import gov.nasa.jpl.hi.marsimages.ui.ImageViewActivity;
package gov.nasa.jpl.hi.marsimages;
/**
* Created by mpowell on 5/6/14.
*/
public class Utils {
private Utils() {
}
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static void enableStrictMode() {
if (Utils.hasGingerbread()) {
StrictMode.ThreadPolicy.Builder threadPolicyBuilder =
new StrictMode.ThreadPolicy.Builder()
.detectAll()
.penaltyLog();
StrictMode.VmPolicy.Builder vmPolicyBuilder =
new StrictMode.VmPolicy.Builder()
.detectAll()
.penaltyLog();
if (Utils.hasHoneycomb()) {
threadPolicyBuilder.penaltyFlashScreen();
vmPolicyBuilder | .setClassInstanceLimit(ImageViewActivity.class, 1); |
OpsLabJPL/MarsImagesAndroid | MarsImages/Rajawali/src/main/java/rajawali/math/Quaternion.java | // Path: MarsImages/Rajawali/src/main/java/rajawali/math/Number3D.java
// public enum Axis {
// X, Y, Z
// }
| import rajawali.math.Number3D.Axis; | this.y = y;
this.z = z;
}
public Quaternion(Quaternion other) {
this();
this.w = other.w;
this.x = other.x;
this.y = other.y;
this.z = other.z;
}
public void setAllFrom(Quaternion other) {
this.w = other.w;
this.x = other.x;
this.y = other.y;
this.z = other.z;
}
public Quaternion clone() {
return new Quaternion(w, x, y, z);
}
public void setAll(float w, float x, float y, float z) {
this.w = w;
this.x = x;
this.y = y;
this.z = z;
}
| // Path: MarsImages/Rajawali/src/main/java/rajawali/math/Number3D.java
// public enum Axis {
// X, Y, Z
// }
// Path: MarsImages/Rajawali/src/main/java/rajawali/math/Quaternion.java
import rajawali.math.Number3D.Axis;
this.y = y;
this.z = z;
}
public Quaternion(Quaternion other) {
this();
this.w = other.w;
this.x = other.x;
this.y = other.y;
this.z = other.z;
}
public void setAllFrom(Quaternion other) {
this.w = other.w;
this.x = other.x;
this.y = other.y;
this.z = other.z;
}
public Quaternion clone() {
return new Quaternion(w, x, y, z);
}
public void setAll(float w, float x, float y, float z) {
this.w = w;
this.x = x;
this.y = y;
this.z = z;
}
| public Quaternion fromAngleAxis(final float angle, final Axis axis) { |
OpsLabJPL/MarsImagesAndroid | MarsImages/MarsImages/src/main/java/gov/nasa/jpl/hi/marsimages/ui/ImageViewActivity.java | // Path: MarsImages/MarsImages/src/main/java/gov/nasa/jpl/hi/marsimages/EvernoteMars.java
// public static final EvernoteMars EVERNOTE = new EvernoteMars();
//
// Path: MarsImages/MarsImages/src/main/java/gov/nasa/jpl/hi/marsimages/MarsImagesApp.java
// public static MarsImagesApp MARS_IMAGES;
| import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.powellware.marsimages.R;
import static gov.nasa.jpl.hi.marsimages.EvernoteMars.EVERNOTE;
import static gov.nasa.jpl.hi.marsimages.MarsImagesApp.MARS_IMAGES; | package gov.nasa.jpl.hi.marsimages.ui;
public class ImageViewActivity extends AppCompatActivity {
private ImageViewPagerFragment imageViewPagerFragment;
@Override
public void onCreate(Bundle savedInstanceState) {
// Utils.enableStrictMode();
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_image_view);
int selectedPage = getIntent().getIntExtra(ImageViewPagerFragment.STATE_PAGE_NUMBER, 0);
imageViewPagerFragment = (ImageViewPagerFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_image_view_pager);
imageViewPagerFragment.setUpViewPager(selectedPage);
}
@Override
public void onResume() {
super.onResume(); | // Path: MarsImages/MarsImages/src/main/java/gov/nasa/jpl/hi/marsimages/EvernoteMars.java
// public static final EvernoteMars EVERNOTE = new EvernoteMars();
//
// Path: MarsImages/MarsImages/src/main/java/gov/nasa/jpl/hi/marsimages/MarsImagesApp.java
// public static MarsImagesApp MARS_IMAGES;
// Path: MarsImages/MarsImages/src/main/java/gov/nasa/jpl/hi/marsimages/ui/ImageViewActivity.java
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.powellware.marsimages.R;
import static gov.nasa.jpl.hi.marsimages.EvernoteMars.EVERNOTE;
import static gov.nasa.jpl.hi.marsimages.MarsImagesApp.MARS_IMAGES;
package gov.nasa.jpl.hi.marsimages.ui;
public class ImageViewActivity extends AppCompatActivity {
private ImageViewPagerFragment imageViewPagerFragment;
@Override
public void onCreate(Bundle savedInstanceState) {
// Utils.enableStrictMode();
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_image_view);
int selectedPage = getIntent().getIntExtra(ImageViewPagerFragment.STATE_PAGE_NUMBER, 0);
imageViewPagerFragment = (ImageViewPagerFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_image_view_pager);
imageViewPagerFragment.setUpViewPager(selectedPage);
}
@Override
public void onResume() {
super.onResume(); | long pauseTimeMillis = MARS_IMAGES.getPauseTimestamp(); |
OpsLabJPL/MarsImagesAndroid | MarsImages/MarsImages/src/main/java/gov/nasa/jpl/hi/marsimages/ui/ImageViewActivity.java | // Path: MarsImages/MarsImages/src/main/java/gov/nasa/jpl/hi/marsimages/EvernoteMars.java
// public static final EvernoteMars EVERNOTE = new EvernoteMars();
//
// Path: MarsImages/MarsImages/src/main/java/gov/nasa/jpl/hi/marsimages/MarsImagesApp.java
// public static MarsImagesApp MARS_IMAGES;
| import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.powellware.marsimages.R;
import static gov.nasa.jpl.hi.marsimages.EvernoteMars.EVERNOTE;
import static gov.nasa.jpl.hi.marsimages.MarsImagesApp.MARS_IMAGES; | package gov.nasa.jpl.hi.marsimages.ui;
public class ImageViewActivity extends AppCompatActivity {
private ImageViewPagerFragment imageViewPagerFragment;
@Override
public void onCreate(Bundle savedInstanceState) {
// Utils.enableStrictMode();
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_image_view);
int selectedPage = getIntent().getIntExtra(ImageViewPagerFragment.STATE_PAGE_NUMBER, 0);
imageViewPagerFragment = (ImageViewPagerFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_image_view_pager);
imageViewPagerFragment.setUpViewPager(selectedPage);
}
@Override
public void onResume() {
super.onResume();
long pauseTimeMillis = MARS_IMAGES.getPauseTimestamp();
ImageLoader.getInstance().resume();
if (pauseTimeMillis > 0 && System.currentTimeMillis() - pauseTimeMillis > 30 * 60 * 1000) | // Path: MarsImages/MarsImages/src/main/java/gov/nasa/jpl/hi/marsimages/EvernoteMars.java
// public static final EvernoteMars EVERNOTE = new EvernoteMars();
//
// Path: MarsImages/MarsImages/src/main/java/gov/nasa/jpl/hi/marsimages/MarsImagesApp.java
// public static MarsImagesApp MARS_IMAGES;
// Path: MarsImages/MarsImages/src/main/java/gov/nasa/jpl/hi/marsimages/ui/ImageViewActivity.java
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.powellware.marsimages.R;
import static gov.nasa.jpl.hi.marsimages.EvernoteMars.EVERNOTE;
import static gov.nasa.jpl.hi.marsimages.MarsImagesApp.MARS_IMAGES;
package gov.nasa.jpl.hi.marsimages.ui;
public class ImageViewActivity extends AppCompatActivity {
private ImageViewPagerFragment imageViewPagerFragment;
@Override
public void onCreate(Bundle savedInstanceState) {
// Utils.enableStrictMode();
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_image_view);
int selectedPage = getIntent().getIntExtra(ImageViewPagerFragment.STATE_PAGE_NUMBER, 0);
imageViewPagerFragment = (ImageViewPagerFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_image_view_pager);
imageViewPagerFragment.setUpViewPager(selectedPage);
}
@Override
public void onResume() {
super.onResume();
long pauseTimeMillis = MARS_IMAGES.getPauseTimestamp();
ImageLoader.getInstance().resume();
if (pauseTimeMillis > 0 && System.currentTimeMillis() - pauseTimeMillis > 30 * 60 * 1000) | EVERNOTE.loadMoreImages(this, true); |
OpsLabJPL/MarsImagesAndroid | MarsImages/Rajawali/src/main/java/rajawali/materials/DiffuseMaterial.java | // Path: MarsImages/Rajawali/src/main/java/rajawali/lights/ALight.java
// public abstract class ALight extends ATransformable3D {
// public static final int DIRECTIONAL_LIGHT = 0;
// public static final int POINT_LIGHT = 1;
// public static final int SPOT_LIGHT = 2;
//
// protected float[] mColor = new float[] { 1.0f, 1.0f, 1.0f };
// protected float[] mPositionArray = new float[3];
// protected float[] mDirectionArray = new float[3];
// protected float mPower = .5f;
// private int mLightType;
//
// protected boolean mUseObjectTransform;
//
// public ALight(int lightType) {
// super();
// mLightType = lightType;
// }
//
// public void setColor(final float r, final float g, final float b) {
// mColor[0] = r;
// mColor[1] = g;
// mColor[2] = b;
// }
//
// public void setColor(int color) {
// mColor[0] = ((color >> 16) & 0xFF) / 255f;
// mColor[1] = ((color >> 8) & 0xFF) / 255f;
// mColor[2] = (color & 0xFF) / 255f;
// }
//
// public void setColor(Number3D color) {
// mColor[0] = color.x;
// mColor[1] = color.y;
// mColor[2] = color.z;
// }
//
// public float[] getColor() {
// return mColor;
// }
//
// public void setPower(float power) {
// mPower = power;
// }
//
// public float getPower() {
// return mPower;
// }
//
// public boolean shouldUseObjectTransform() {
// return mUseObjectTransform;
// }
//
// public void shouldUseObjectTransform(boolean useObjectTransform) {
// this.mUseObjectTransform = useObjectTransform;
// }
//
// public int getLightType() {
// return mLightType;
// }
//
// public void setLightType(int lightType) {
// this.mLightType = lightType;
// }
//
// public float[] getPositionArray() {
// mPositionArray[0] = mPosition.x;
// mPositionArray[1] = mPosition.y;
// mPositionArray[2] = mPosition.z;
// return mPositionArray;
// }
// }
| import rajawali.lights.ALight;
import com.monyetmabuk.livewallpapers.photosdof.R; | package rajawali.materials;
public class DiffuseMaterial extends AAdvancedMaterial {
public DiffuseMaterial() {
this(false);
}
public DiffuseMaterial(String vertexShader, String fragmentShader, boolean isAnimated) {
super(vertexShader, fragmentShader, isAnimated);
}
public DiffuseMaterial(int vertex_resID, int fragment_resID, boolean isAnimated) {
super(vertex_resID, fragment_resID, isAnimated);
}
public DiffuseMaterial(boolean isAnimated) {
this(R.raw.diffuse_material_vertex, R.raw.diffuse_material_fragment, isAnimated);
}
public DiffuseMaterial(int parameters) {
super(R.raw.diffuse_material_vertex, R.raw.diffuse_material_fragment, parameters);
}
public DiffuseMaterial(String vertexShader, String fragmentShader) {
super(vertexShader, fragmentShader);
}
public void setShaders(String vertexShader, String fragmentShader) {
StringBuffer fc = new StringBuffer();
StringBuffer vc = new StringBuffer();
for(int i=0; i<mLights.size(); ++i) { | // Path: MarsImages/Rajawali/src/main/java/rajawali/lights/ALight.java
// public abstract class ALight extends ATransformable3D {
// public static final int DIRECTIONAL_LIGHT = 0;
// public static final int POINT_LIGHT = 1;
// public static final int SPOT_LIGHT = 2;
//
// protected float[] mColor = new float[] { 1.0f, 1.0f, 1.0f };
// protected float[] mPositionArray = new float[3];
// protected float[] mDirectionArray = new float[3];
// protected float mPower = .5f;
// private int mLightType;
//
// protected boolean mUseObjectTransform;
//
// public ALight(int lightType) {
// super();
// mLightType = lightType;
// }
//
// public void setColor(final float r, final float g, final float b) {
// mColor[0] = r;
// mColor[1] = g;
// mColor[2] = b;
// }
//
// public void setColor(int color) {
// mColor[0] = ((color >> 16) & 0xFF) / 255f;
// mColor[1] = ((color >> 8) & 0xFF) / 255f;
// mColor[2] = (color & 0xFF) / 255f;
// }
//
// public void setColor(Number3D color) {
// mColor[0] = color.x;
// mColor[1] = color.y;
// mColor[2] = color.z;
// }
//
// public float[] getColor() {
// return mColor;
// }
//
// public void setPower(float power) {
// mPower = power;
// }
//
// public float getPower() {
// return mPower;
// }
//
// public boolean shouldUseObjectTransform() {
// return mUseObjectTransform;
// }
//
// public void shouldUseObjectTransform(boolean useObjectTransform) {
// this.mUseObjectTransform = useObjectTransform;
// }
//
// public int getLightType() {
// return mLightType;
// }
//
// public void setLightType(int lightType) {
// this.mLightType = lightType;
// }
//
// public float[] getPositionArray() {
// mPositionArray[0] = mPosition.x;
// mPositionArray[1] = mPosition.y;
// mPositionArray[2] = mPosition.z;
// return mPositionArray;
// }
// }
// Path: MarsImages/Rajawali/src/main/java/rajawali/materials/DiffuseMaterial.java
import rajawali.lights.ALight;
import com.monyetmabuk.livewallpapers.photosdof.R;
package rajawali.materials;
public class DiffuseMaterial extends AAdvancedMaterial {
public DiffuseMaterial() {
this(false);
}
public DiffuseMaterial(String vertexShader, String fragmentShader, boolean isAnimated) {
super(vertexShader, fragmentShader, isAnimated);
}
public DiffuseMaterial(int vertex_resID, int fragment_resID, boolean isAnimated) {
super(vertex_resID, fragment_resID, isAnimated);
}
public DiffuseMaterial(boolean isAnimated) {
this(R.raw.diffuse_material_vertex, R.raw.diffuse_material_fragment, isAnimated);
}
public DiffuseMaterial(int parameters) {
super(R.raw.diffuse_material_vertex, R.raw.diffuse_material_fragment, parameters);
}
public DiffuseMaterial(String vertexShader, String fragmentShader) {
super(vertexShader, fragmentShader);
}
public void setShaders(String vertexShader, String fragmentShader) {
StringBuffer fc = new StringBuffer();
StringBuffer vc = new StringBuffer();
for(int i=0; i<mLights.size(); ++i) { | ALight light = mLights.get(i); |
OpsLabJPL/MarsImagesAndroid | MarsImages/Rajawali/src/main/java/rajawali/materials/BumpmapPhongMaterial.java | // Path: MarsImages/Rajawali/src/main/java/rajawali/lights/ALight.java
// public abstract class ALight extends ATransformable3D {
// public static final int DIRECTIONAL_LIGHT = 0;
// public static final int POINT_LIGHT = 1;
// public static final int SPOT_LIGHT = 2;
//
// protected float[] mColor = new float[] { 1.0f, 1.0f, 1.0f };
// protected float[] mPositionArray = new float[3];
// protected float[] mDirectionArray = new float[3];
// protected float mPower = .5f;
// private int mLightType;
//
// protected boolean mUseObjectTransform;
//
// public ALight(int lightType) {
// super();
// mLightType = lightType;
// }
//
// public void setColor(final float r, final float g, final float b) {
// mColor[0] = r;
// mColor[1] = g;
// mColor[2] = b;
// }
//
// public void setColor(int color) {
// mColor[0] = ((color >> 16) & 0xFF) / 255f;
// mColor[1] = ((color >> 8) & 0xFF) / 255f;
// mColor[2] = (color & 0xFF) / 255f;
// }
//
// public void setColor(Number3D color) {
// mColor[0] = color.x;
// mColor[1] = color.y;
// mColor[2] = color.z;
// }
//
// public float[] getColor() {
// return mColor;
// }
//
// public void setPower(float power) {
// mPower = power;
// }
//
// public float getPower() {
// return mPower;
// }
//
// public boolean shouldUseObjectTransform() {
// return mUseObjectTransform;
// }
//
// public void shouldUseObjectTransform(boolean useObjectTransform) {
// this.mUseObjectTransform = useObjectTransform;
// }
//
// public int getLightType() {
// return mLightType;
// }
//
// public void setLightType(int lightType) {
// this.mLightType = lightType;
// }
//
// public float[] getPositionArray() {
// mPositionArray[0] = mPosition.x;
// mPositionArray[1] = mPosition.y;
// mPositionArray[2] = mPosition.z;
// return mPositionArray;
// }
// }
| import rajawali.lights.ALight;
import com.monyetmabuk.livewallpapers.photosdof.R; | package rajawali.materials;
public class BumpmapPhongMaterial extends PhongMaterial {
public BumpmapPhongMaterial() {
this(false);
}
public BumpmapPhongMaterial(boolean isAnimated) {
super(R.raw.phong_material_vertex, R.raw.bumpmap_phong_material, isAnimated);
}
@Override
public void setShaders(String vertexShader, String fragmentShader)
{
StringBuffer fc = new StringBuffer();
StringBuffer vc = new StringBuffer();
fc.append("float normPower = 0.0;\n");
for(int i=0; i<mLights.size(); ++i) { | // Path: MarsImages/Rajawali/src/main/java/rajawali/lights/ALight.java
// public abstract class ALight extends ATransformable3D {
// public static final int DIRECTIONAL_LIGHT = 0;
// public static final int POINT_LIGHT = 1;
// public static final int SPOT_LIGHT = 2;
//
// protected float[] mColor = new float[] { 1.0f, 1.0f, 1.0f };
// protected float[] mPositionArray = new float[3];
// protected float[] mDirectionArray = new float[3];
// protected float mPower = .5f;
// private int mLightType;
//
// protected boolean mUseObjectTransform;
//
// public ALight(int lightType) {
// super();
// mLightType = lightType;
// }
//
// public void setColor(final float r, final float g, final float b) {
// mColor[0] = r;
// mColor[1] = g;
// mColor[2] = b;
// }
//
// public void setColor(int color) {
// mColor[0] = ((color >> 16) & 0xFF) / 255f;
// mColor[1] = ((color >> 8) & 0xFF) / 255f;
// mColor[2] = (color & 0xFF) / 255f;
// }
//
// public void setColor(Number3D color) {
// mColor[0] = color.x;
// mColor[1] = color.y;
// mColor[2] = color.z;
// }
//
// public float[] getColor() {
// return mColor;
// }
//
// public void setPower(float power) {
// mPower = power;
// }
//
// public float getPower() {
// return mPower;
// }
//
// public boolean shouldUseObjectTransform() {
// return mUseObjectTransform;
// }
//
// public void shouldUseObjectTransform(boolean useObjectTransform) {
// this.mUseObjectTransform = useObjectTransform;
// }
//
// public int getLightType() {
// return mLightType;
// }
//
// public void setLightType(int lightType) {
// this.mLightType = lightType;
// }
//
// public float[] getPositionArray() {
// mPositionArray[0] = mPosition.x;
// mPositionArray[1] = mPosition.y;
// mPositionArray[2] = mPosition.z;
// return mPositionArray;
// }
// }
// Path: MarsImages/Rajawali/src/main/java/rajawali/materials/BumpmapPhongMaterial.java
import rajawali.lights.ALight;
import com.monyetmabuk.livewallpapers.photosdof.R;
package rajawali.materials;
public class BumpmapPhongMaterial extends PhongMaterial {
public BumpmapPhongMaterial() {
this(false);
}
public BumpmapPhongMaterial(boolean isAnimated) {
super(R.raw.phong_material_vertex, R.raw.bumpmap_phong_material, isAnimated);
}
@Override
public void setShaders(String vertexShader, String fragmentShader)
{
StringBuffer fc = new StringBuffer();
StringBuffer vc = new StringBuffer();
fc.append("float normPower = 0.0;\n");
for(int i=0; i<mLights.size(); ++i) { | ALight light = mLights.get(i); |
OpsLabJPL/MarsImagesAndroid | MarsImages/Rajawali/src/main/java/rajawali/materials/GouraudMaterial.java | // Path: MarsImages/Rajawali/src/main/java/rajawali/lights/ALight.java
// public abstract class ALight extends ATransformable3D {
// public static final int DIRECTIONAL_LIGHT = 0;
// public static final int POINT_LIGHT = 1;
// public static final int SPOT_LIGHT = 2;
//
// protected float[] mColor = new float[] { 1.0f, 1.0f, 1.0f };
// protected float[] mPositionArray = new float[3];
// protected float[] mDirectionArray = new float[3];
// protected float mPower = .5f;
// private int mLightType;
//
// protected boolean mUseObjectTransform;
//
// public ALight(int lightType) {
// super();
// mLightType = lightType;
// }
//
// public void setColor(final float r, final float g, final float b) {
// mColor[0] = r;
// mColor[1] = g;
// mColor[2] = b;
// }
//
// public void setColor(int color) {
// mColor[0] = ((color >> 16) & 0xFF) / 255f;
// mColor[1] = ((color >> 8) & 0xFF) / 255f;
// mColor[2] = (color & 0xFF) / 255f;
// }
//
// public void setColor(Number3D color) {
// mColor[0] = color.x;
// mColor[1] = color.y;
// mColor[2] = color.z;
// }
//
// public float[] getColor() {
// return mColor;
// }
//
// public void setPower(float power) {
// mPower = power;
// }
//
// public float getPower() {
// return mPower;
// }
//
// public boolean shouldUseObjectTransform() {
// return mUseObjectTransform;
// }
//
// public void shouldUseObjectTransform(boolean useObjectTransform) {
// this.mUseObjectTransform = useObjectTransform;
// }
//
// public int getLightType() {
// return mLightType;
// }
//
// public void setLightType(int lightType) {
// this.mLightType = lightType;
// }
//
// public float[] getPositionArray() {
// mPositionArray[0] = mPosition.x;
// mPositionArray[1] = mPosition.y;
// mPositionArray[2] = mPosition.z;
// return mPositionArray;
// }
// }
| import rajawali.lights.ALight;
import android.graphics.Color;
import android.opengl.GLES20;
import com.monyetmabuk.livewallpapers.photosdof.R; | }
public void setSpecularColor(float r, float g, float b, float a) {
mSpecularColor[0] = r;
mSpecularColor[1] = g;
mSpecularColor[2] = b;
mSpecularColor[3] = a;
}
public void setSpecularColor(int color) {
setSpecularColor(Color.red(color) / 255f, Color.green(color) / 255f, Color.blue(color) / 255f, Color.alpha(color) / 255f);
}
public void setSpecularIntensity(float[] intensity) {
mSpecularIntensity = intensity;
}
public void setSpecularIntensity(float r, float g, float b, float a) {
mSpecularIntensity[0] = r;
mSpecularIntensity[1] = g;
mSpecularIntensity[2] = b;
mSpecularIntensity[3] = a;
}
public void setShaders(String vertexShader, String fragmentShader)
{
StringBuffer vc = new StringBuffer();
vc.append("float power = 0.0;\n");
for(int i=0; i<mLights.size(); ++i) { | // Path: MarsImages/Rajawali/src/main/java/rajawali/lights/ALight.java
// public abstract class ALight extends ATransformable3D {
// public static final int DIRECTIONAL_LIGHT = 0;
// public static final int POINT_LIGHT = 1;
// public static final int SPOT_LIGHT = 2;
//
// protected float[] mColor = new float[] { 1.0f, 1.0f, 1.0f };
// protected float[] mPositionArray = new float[3];
// protected float[] mDirectionArray = new float[3];
// protected float mPower = .5f;
// private int mLightType;
//
// protected boolean mUseObjectTransform;
//
// public ALight(int lightType) {
// super();
// mLightType = lightType;
// }
//
// public void setColor(final float r, final float g, final float b) {
// mColor[0] = r;
// mColor[1] = g;
// mColor[2] = b;
// }
//
// public void setColor(int color) {
// mColor[0] = ((color >> 16) & 0xFF) / 255f;
// mColor[1] = ((color >> 8) & 0xFF) / 255f;
// mColor[2] = (color & 0xFF) / 255f;
// }
//
// public void setColor(Number3D color) {
// mColor[0] = color.x;
// mColor[1] = color.y;
// mColor[2] = color.z;
// }
//
// public float[] getColor() {
// return mColor;
// }
//
// public void setPower(float power) {
// mPower = power;
// }
//
// public float getPower() {
// return mPower;
// }
//
// public boolean shouldUseObjectTransform() {
// return mUseObjectTransform;
// }
//
// public void shouldUseObjectTransform(boolean useObjectTransform) {
// this.mUseObjectTransform = useObjectTransform;
// }
//
// public int getLightType() {
// return mLightType;
// }
//
// public void setLightType(int lightType) {
// this.mLightType = lightType;
// }
//
// public float[] getPositionArray() {
// mPositionArray[0] = mPosition.x;
// mPositionArray[1] = mPosition.y;
// mPositionArray[2] = mPosition.z;
// return mPositionArray;
// }
// }
// Path: MarsImages/Rajawali/src/main/java/rajawali/materials/GouraudMaterial.java
import rajawali.lights.ALight;
import android.graphics.Color;
import android.opengl.GLES20;
import com.monyetmabuk.livewallpapers.photosdof.R;
}
public void setSpecularColor(float r, float g, float b, float a) {
mSpecularColor[0] = r;
mSpecularColor[1] = g;
mSpecularColor[2] = b;
mSpecularColor[3] = a;
}
public void setSpecularColor(int color) {
setSpecularColor(Color.red(color) / 255f, Color.green(color) / 255f, Color.blue(color) / 255f, Color.alpha(color) / 255f);
}
public void setSpecularIntensity(float[] intensity) {
mSpecularIntensity = intensity;
}
public void setSpecularIntensity(float r, float g, float b, float a) {
mSpecularIntensity[0] = r;
mSpecularIntensity[1] = g;
mSpecularIntensity[2] = b;
mSpecularIntensity[3] = a;
}
public void setShaders(String vertexShader, String fragmentShader)
{
StringBuffer vc = new StringBuffer();
vc.append("float power = 0.0;\n");
for(int i=0; i<mLights.size(); ++i) { | ALight light = mLights.get(i); |
OpsLabJPL/MarsImagesAndroid | MarsImages/Rajawali/src/main/java/rajawali/materials/BumpmapMaterial.java | // Path: MarsImages/Rajawali/src/main/java/rajawali/lights/ALight.java
// public abstract class ALight extends ATransformable3D {
// public static final int DIRECTIONAL_LIGHT = 0;
// public static final int POINT_LIGHT = 1;
// public static final int SPOT_LIGHT = 2;
//
// protected float[] mColor = new float[] { 1.0f, 1.0f, 1.0f };
// protected float[] mPositionArray = new float[3];
// protected float[] mDirectionArray = new float[3];
// protected float mPower = .5f;
// private int mLightType;
//
// protected boolean mUseObjectTransform;
//
// public ALight(int lightType) {
// super();
// mLightType = lightType;
// }
//
// public void setColor(final float r, final float g, final float b) {
// mColor[0] = r;
// mColor[1] = g;
// mColor[2] = b;
// }
//
// public void setColor(int color) {
// mColor[0] = ((color >> 16) & 0xFF) / 255f;
// mColor[1] = ((color >> 8) & 0xFF) / 255f;
// mColor[2] = (color & 0xFF) / 255f;
// }
//
// public void setColor(Number3D color) {
// mColor[0] = color.x;
// mColor[1] = color.y;
// mColor[2] = color.z;
// }
//
// public float[] getColor() {
// return mColor;
// }
//
// public void setPower(float power) {
// mPower = power;
// }
//
// public float getPower() {
// return mPower;
// }
//
// public boolean shouldUseObjectTransform() {
// return mUseObjectTransform;
// }
//
// public void shouldUseObjectTransform(boolean useObjectTransform) {
// this.mUseObjectTransform = useObjectTransform;
// }
//
// public int getLightType() {
// return mLightType;
// }
//
// public void setLightType(int lightType) {
// this.mLightType = lightType;
// }
//
// public float[] getPositionArray() {
// mPositionArray[0] = mPosition.x;
// mPositionArray[1] = mPosition.y;
// mPositionArray[2] = mPosition.z;
// return mPositionArray;
// }
// }
| import com.monyetmabuk.livewallpapers.photosdof.R;
import rajawali.lights.ALight; | package rajawali.materials;
public class BumpmapMaterial extends AAdvancedMaterial {
public BumpmapMaterial() {
this(false);
}
public BumpmapMaterial(String vertexShader, String fragmentShader, boolean isAnimated) {
super(vertexShader, fragmentShader, isAnimated);
}
public BumpmapMaterial(boolean isAnimated) {
super(R.raw.diffuse_material_vertex, R.raw.bumpmap_material_fragment, isAnimated);
}
public void setShaders(String vertexShader, String fragmentShader) {
StringBuffer fc = new StringBuffer();
StringBuffer vc = new StringBuffer();
fc.append("float normPower = 0.0;\n");
for(int i=0; i<mLights.size(); ++i) { | // Path: MarsImages/Rajawali/src/main/java/rajawali/lights/ALight.java
// public abstract class ALight extends ATransformable3D {
// public static final int DIRECTIONAL_LIGHT = 0;
// public static final int POINT_LIGHT = 1;
// public static final int SPOT_LIGHT = 2;
//
// protected float[] mColor = new float[] { 1.0f, 1.0f, 1.0f };
// protected float[] mPositionArray = new float[3];
// protected float[] mDirectionArray = new float[3];
// protected float mPower = .5f;
// private int mLightType;
//
// protected boolean mUseObjectTransform;
//
// public ALight(int lightType) {
// super();
// mLightType = lightType;
// }
//
// public void setColor(final float r, final float g, final float b) {
// mColor[0] = r;
// mColor[1] = g;
// mColor[2] = b;
// }
//
// public void setColor(int color) {
// mColor[0] = ((color >> 16) & 0xFF) / 255f;
// mColor[1] = ((color >> 8) & 0xFF) / 255f;
// mColor[2] = (color & 0xFF) / 255f;
// }
//
// public void setColor(Number3D color) {
// mColor[0] = color.x;
// mColor[1] = color.y;
// mColor[2] = color.z;
// }
//
// public float[] getColor() {
// return mColor;
// }
//
// public void setPower(float power) {
// mPower = power;
// }
//
// public float getPower() {
// return mPower;
// }
//
// public boolean shouldUseObjectTransform() {
// return mUseObjectTransform;
// }
//
// public void shouldUseObjectTransform(boolean useObjectTransform) {
// this.mUseObjectTransform = useObjectTransform;
// }
//
// public int getLightType() {
// return mLightType;
// }
//
// public void setLightType(int lightType) {
// this.mLightType = lightType;
// }
//
// public float[] getPositionArray() {
// mPositionArray[0] = mPosition.x;
// mPositionArray[1] = mPosition.y;
// mPositionArray[2] = mPosition.z;
// return mPositionArray;
// }
// }
// Path: MarsImages/Rajawali/src/main/java/rajawali/materials/BumpmapMaterial.java
import com.monyetmabuk.livewallpapers.photosdof.R;
import rajawali.lights.ALight;
package rajawali.materials;
public class BumpmapMaterial extends AAdvancedMaterial {
public BumpmapMaterial() {
this(false);
}
public BumpmapMaterial(String vertexShader, String fragmentShader, boolean isAnimated) {
super(vertexShader, fragmentShader, isAnimated);
}
public BumpmapMaterial(boolean isAnimated) {
super(R.raw.diffuse_material_vertex, R.raw.bumpmap_material_fragment, isAnimated);
}
public void setShaders(String vertexShader, String fragmentShader) {
StringBuffer fc = new StringBuffer();
StringBuffer vc = new StringBuffer();
fc.append("float normPower = 0.0;\n");
for(int i=0; i<mLights.size(); ++i) { | ALight light = mLights.get(i); |
OpsLabJPL/MarsImagesAndroid | MarsImages/MarsImages/src/main/java/gov/nasa/jpl/hi/marsimages/ui/MapActivity.java | // Path: MarsImages/MarsImages/src/main/java/gov/nasa/jpl/hi/marsimages/JsonReader.java
// public class JsonReader {
// public static JSONObject readJsonFromUrl(String url) throws IOException, JSONException {
// InputStream is = new URL(url).openStream();
// //noinspection TryFinallyCanBeTryWithResources
// try {
// BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
// String jsonText = readAll(rd);
// return new JSONObject(jsonText);
// } finally {
// is.close();
// }
// }
//
// private static String readAll(Reader rd) throws IOException {
// StringBuilder sb = new StringBuilder();
// int cp;
// while ((cp = rd.read()) != -1) {
// sb.append((char) cp);
// }
// return sb.toString();
// }
// }
//
// Path: MarsImages/MarsImages/src/main/java/gov/nasa/jpl/hi/marsimages/MarsImagesApp.java
// public static MarsImagesApp MARS_IMAGES;
| import android.graphics.PointF;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.FrameLayout;
import com.mapbox.mapboxsdk.geometry.BoundingBox;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.overlay.Marker;
import com.mapbox.mapboxsdk.views.MapView;
import com.powellware.marsimages.R;
import org.apache.commons.csv.CSVRecord;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import gov.nasa.jpl.hi.marsimages.JsonReader;
import static gov.nasa.jpl.hi.marsimages.MarsImagesApp.MARS_IMAGES; | package gov.nasa.jpl.hi.marsimages.ui;
public class MapActivity extends AppCompatActivity {
public static final String INTENT_ACTION_MAP = "gov.nasa.jpl.hi.marsimages.MAP";
private static final String MAP = "MissionMap";
private String tileSet;
private int minZoom;
private int maxZoom;
private int maxNativeZoom;
private int defaultZoom;
private double centerLat;
private double centerLon;
private double upperLeftLat;
private double upperLeftLon;
private double upperRightLat;
private double upperRightLon;
private double lowerLeftLat;
private double lowerLeftLon;
private int mapPixelWidth;
private int mapPixelHeight;
private int latestSiteIndex;
private MapView mapView;
private ArrayList<LatLng> points;
private HashMap<Integer, int[]> rmcsForPoints;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map);
final FrameLayout frameLayout = (FrameLayout) findViewById(R.id.mapContainer); | // Path: MarsImages/MarsImages/src/main/java/gov/nasa/jpl/hi/marsimages/JsonReader.java
// public class JsonReader {
// public static JSONObject readJsonFromUrl(String url) throws IOException, JSONException {
// InputStream is = new URL(url).openStream();
// //noinspection TryFinallyCanBeTryWithResources
// try {
// BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
// String jsonText = readAll(rd);
// return new JSONObject(jsonText);
// } finally {
// is.close();
// }
// }
//
// private static String readAll(Reader rd) throws IOException {
// StringBuilder sb = new StringBuilder();
// int cp;
// while ((cp = rd.read()) != -1) {
// sb.append((char) cp);
// }
// return sb.toString();
// }
// }
//
// Path: MarsImages/MarsImages/src/main/java/gov/nasa/jpl/hi/marsimages/MarsImagesApp.java
// public static MarsImagesApp MARS_IMAGES;
// Path: MarsImages/MarsImages/src/main/java/gov/nasa/jpl/hi/marsimages/ui/MapActivity.java
import android.graphics.PointF;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.FrameLayout;
import com.mapbox.mapboxsdk.geometry.BoundingBox;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.overlay.Marker;
import com.mapbox.mapboxsdk.views.MapView;
import com.powellware.marsimages.R;
import org.apache.commons.csv.CSVRecord;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import gov.nasa.jpl.hi.marsimages.JsonReader;
import static gov.nasa.jpl.hi.marsimages.MarsImagesApp.MARS_IMAGES;
package gov.nasa.jpl.hi.marsimages.ui;
public class MapActivity extends AppCompatActivity {
public static final String INTENT_ACTION_MAP = "gov.nasa.jpl.hi.marsimages.MAP";
private static final String MAP = "MissionMap";
private String tileSet;
private int minZoom;
private int maxZoom;
private int maxNativeZoom;
private int defaultZoom;
private double centerLat;
private double centerLon;
private double upperLeftLat;
private double upperLeftLon;
private double upperRightLat;
private double upperRightLon;
private double lowerLeftLat;
private double lowerLeftLon;
private int mapPixelWidth;
private int mapPixelHeight;
private int latestSiteIndex;
private MapView mapView;
private ArrayList<LatLng> points;
private HashMap<Integer, int[]> rmcsForPoints;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map);
final FrameLayout frameLayout = (FrameLayout) findViewById(R.id.mapContainer); | String missionName = MARS_IMAGES.getMissionName(); |
OpsLabJPL/MarsImagesAndroid | MarsImages/MarsImages/src/main/java/gov/nasa/jpl/hi/marsimages/ui/MapActivity.java | // Path: MarsImages/MarsImages/src/main/java/gov/nasa/jpl/hi/marsimages/JsonReader.java
// public class JsonReader {
// public static JSONObject readJsonFromUrl(String url) throws IOException, JSONException {
// InputStream is = new URL(url).openStream();
// //noinspection TryFinallyCanBeTryWithResources
// try {
// BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
// String jsonText = readAll(rd);
// return new JSONObject(jsonText);
// } finally {
// is.close();
// }
// }
//
// private static String readAll(Reader rd) throws IOException {
// StringBuilder sb = new StringBuilder();
// int cp;
// while ((cp = rd.read()) != -1) {
// sb.append((char) cp);
// }
// return sb.toString();
// }
// }
//
// Path: MarsImages/MarsImages/src/main/java/gov/nasa/jpl/hi/marsimages/MarsImagesApp.java
// public static MarsImagesApp MARS_IMAGES;
| import android.graphics.PointF;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.FrameLayout;
import com.mapbox.mapboxsdk.geometry.BoundingBox;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.overlay.Marker;
import com.mapbox.mapboxsdk.views.MapView;
import com.powellware.marsimages.R;
import org.apache.commons.csv.CSVRecord;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import gov.nasa.jpl.hi.marsimages.JsonReader;
import static gov.nasa.jpl.hi.marsimages.MarsImagesApp.MARS_IMAGES; | private int maxZoom;
private int maxNativeZoom;
private int defaultZoom;
private double centerLat;
private double centerLon;
private double upperLeftLat;
private double upperLeftLon;
private double upperRightLat;
private double upperRightLon;
private double lowerLeftLat;
private double lowerLeftLon;
private int mapPixelWidth;
private int mapPixelHeight;
private int latestSiteIndex;
private MapView mapView;
private ArrayList<LatLng> points;
private HashMap<Integer, int[]> rmcsForPoints;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map);
final FrameLayout frameLayout = (FrameLayout) findViewById(R.id.mapContainer);
String missionName = MARS_IMAGES.getMissionName();
new AsyncTask<String, Void, Void>() {
@Override
protected Void doInBackground(String... params) {
String missionName = params[0];
try {
String url = "http://merpublic.s3.amazonaws.com/maps/" + missionName + "Map.json"; | // Path: MarsImages/MarsImages/src/main/java/gov/nasa/jpl/hi/marsimages/JsonReader.java
// public class JsonReader {
// public static JSONObject readJsonFromUrl(String url) throws IOException, JSONException {
// InputStream is = new URL(url).openStream();
// //noinspection TryFinallyCanBeTryWithResources
// try {
// BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
// String jsonText = readAll(rd);
// return new JSONObject(jsonText);
// } finally {
// is.close();
// }
// }
//
// private static String readAll(Reader rd) throws IOException {
// StringBuilder sb = new StringBuilder();
// int cp;
// while ((cp = rd.read()) != -1) {
// sb.append((char) cp);
// }
// return sb.toString();
// }
// }
//
// Path: MarsImages/MarsImages/src/main/java/gov/nasa/jpl/hi/marsimages/MarsImagesApp.java
// public static MarsImagesApp MARS_IMAGES;
// Path: MarsImages/MarsImages/src/main/java/gov/nasa/jpl/hi/marsimages/ui/MapActivity.java
import android.graphics.PointF;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.FrameLayout;
import com.mapbox.mapboxsdk.geometry.BoundingBox;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.overlay.Marker;
import com.mapbox.mapboxsdk.views.MapView;
import com.powellware.marsimages.R;
import org.apache.commons.csv.CSVRecord;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import gov.nasa.jpl.hi.marsimages.JsonReader;
import static gov.nasa.jpl.hi.marsimages.MarsImagesApp.MARS_IMAGES;
private int maxZoom;
private int maxNativeZoom;
private int defaultZoom;
private double centerLat;
private double centerLon;
private double upperLeftLat;
private double upperLeftLon;
private double upperRightLat;
private double upperRightLon;
private double lowerLeftLat;
private double lowerLeftLon;
private int mapPixelWidth;
private int mapPixelHeight;
private int latestSiteIndex;
private MapView mapView;
private ArrayList<LatLng> points;
private HashMap<Integer, int[]> rmcsForPoints;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map);
final FrameLayout frameLayout = (FrameLayout) findViewById(R.id.mapContainer);
String missionName = MARS_IMAGES.getMissionName();
new AsyncTask<String, Void, Void>() {
@Override
protected Void doInBackground(String... params) {
String missionName = params[0];
try {
String url = "http://merpublic.s3.amazonaws.com/maps/" + missionName + "Map.json"; | JSONObject jsonObject = JsonReader.readJsonFromUrl(url); |
OpsLabJPL/MarsImagesAndroid | MarsImages/MarsImages/src/main/java/gov/nasa/jpl/hi/marsimages/ui/MarsClockActivity.java | // Path: MarsImages/MarsImages/src/main/java/gov/nasa/jpl/hi/marsimages/rovers/Opportunity.java
// public class Opportunity extends Rover.MER {
//
// public Opportunity() {
// eyeIndex = 23;
// instrumentIndex = 1;
// sampleTypeIndex = 12;
// stereoInstruments.addAll(Arrays.asList("F", "R", "N", "P"));
// }
//
// @Override
// public String getUser() {
// return "opportunitymars";
// }
//
// @Override
// public Date getEpoch() {
// try {
// return new SimpleDateFormat(EPOCH_FORMAT).parse("2004012415:08:59GMT");
// } catch (ParseException e) {
// e.printStackTrace();
// }
// return null;
// }
//
// @Override
// public String getURLPrefix() {
// return "http://merpublic.s3.amazonaws.com";
// }
// }
| import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;
import com.powellware.marsimages.R;
import java.text.SimpleDateFormat;
import java.util.Date;
import gov.nasa.jpl.android.marstime.MarsTime;
import gov.nasa.jpl.hi.marsimages.rovers.Opportunity;
import static gov.nasa.jpl.android.marstime.MarsTime.CURIOSITY_WEST_LONGITUDE;
import static gov.nasa.jpl.android.marstime.MarsTime.EARTH_SECS_PER_MARS_SEC; | package gov.nasa.jpl.hi.marsimages.ui;
public class MarsClockActivity extends AppCompatActivity {
public static final String INTENT_ACTION_MARS_TIME = "gov.nasa.jpl.hi.marsimages.MARS_TIME";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_mars_clock);
final TextView earthText = (TextView) findViewById(R.id.earthTimeText);
final TextView oppyText = (TextView) findViewById(R.id.oppyTimeText);
final TextView curioText = (TextView) findViewById(R.id.curioTimeText); | // Path: MarsImages/MarsImages/src/main/java/gov/nasa/jpl/hi/marsimages/rovers/Opportunity.java
// public class Opportunity extends Rover.MER {
//
// public Opportunity() {
// eyeIndex = 23;
// instrumentIndex = 1;
// sampleTypeIndex = 12;
// stereoInstruments.addAll(Arrays.asList("F", "R", "N", "P"));
// }
//
// @Override
// public String getUser() {
// return "opportunitymars";
// }
//
// @Override
// public Date getEpoch() {
// try {
// return new SimpleDateFormat(EPOCH_FORMAT).parse("2004012415:08:59GMT");
// } catch (ParseException e) {
// e.printStackTrace();
// }
// return null;
// }
//
// @Override
// public String getURLPrefix() {
// return "http://merpublic.s3.amazonaws.com";
// }
// }
// Path: MarsImages/MarsImages/src/main/java/gov/nasa/jpl/hi/marsimages/ui/MarsClockActivity.java
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;
import com.powellware.marsimages.R;
import java.text.SimpleDateFormat;
import java.util.Date;
import gov.nasa.jpl.android.marstime.MarsTime;
import gov.nasa.jpl.hi.marsimages.rovers.Opportunity;
import static gov.nasa.jpl.android.marstime.MarsTime.CURIOSITY_WEST_LONGITUDE;
import static gov.nasa.jpl.android.marstime.MarsTime.EARTH_SECS_PER_MARS_SEC;
package gov.nasa.jpl.hi.marsimages.ui;
public class MarsClockActivity extends AppCompatActivity {
public static final String INTENT_ACTION_MARS_TIME = "gov.nasa.jpl.hi.marsimages.MARS_TIME";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_mars_clock);
final TextView earthText = (TextView) findViewById(R.id.earthTimeText);
final TextView oppyText = (TextView) findViewById(R.id.oppyTimeText);
final TextView curioText = (TextView) findViewById(R.id.curioTimeText); | final Opportunity opportunity = new Opportunity(); |
OpsLabJPL/MarsImagesAndroid | MarsImages/Rajawali/src/main/java/rajawali/materials/TextureInfo.java | // Path: MarsImages/Rajawali/src/main/java/rajawali/materials/TextureManager.java
// public enum CompressionType {
// NONE,
// ETC1,
// PALETTED,
// THREEDC,
// ATC,
// DXT1,
// PVRTC
// };
//
// Path: MarsImages/Rajawali/src/main/java/rajawali/materials/TextureManager.java
// public enum FilterType{
// NEAREST,
// LINEAR
// };
//
// Path: MarsImages/Rajawali/src/main/java/rajawali/materials/TextureManager.java
// public enum TextureType {
// DIFFUSE,
// BUMP,
// SPECULAR,
// ALPHA,
// FRAME_BUFFER,
// DEPTH_BUFFER,
// LOOKUP,
// CUBE_MAP,
// SPHERE_MAP,
// VIDEO_TEXTURE
// };
//
// Path: MarsImages/Rajawali/src/main/java/rajawali/materials/TextureManager.java
// public enum WrapType {
// CLAMP,
// REPEAT
// };
| import java.nio.ByteBuffer;
import rajawali.materials.TextureManager.CompressionType;
import rajawali.materials.TextureManager.FilterType;
import rajawali.materials.TextureManager.TextureType;
import rajawali.materials.TextureManager.WrapType;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config; | package rajawali.materials;
/**
* This class contains OpenGL specific texture information.
*
* @author dennis.ippel
*
*/
public class TextureInfo {
/**
* This texture's unique id
*/
protected int mTextureId;
/**
* The type of texture
*
* @see TextureManager.TextureType
*/ | // Path: MarsImages/Rajawali/src/main/java/rajawali/materials/TextureManager.java
// public enum CompressionType {
// NONE,
// ETC1,
// PALETTED,
// THREEDC,
// ATC,
// DXT1,
// PVRTC
// };
//
// Path: MarsImages/Rajawali/src/main/java/rajawali/materials/TextureManager.java
// public enum FilterType{
// NEAREST,
// LINEAR
// };
//
// Path: MarsImages/Rajawali/src/main/java/rajawali/materials/TextureManager.java
// public enum TextureType {
// DIFFUSE,
// BUMP,
// SPECULAR,
// ALPHA,
// FRAME_BUFFER,
// DEPTH_BUFFER,
// LOOKUP,
// CUBE_MAP,
// SPHERE_MAP,
// VIDEO_TEXTURE
// };
//
// Path: MarsImages/Rajawali/src/main/java/rajawali/materials/TextureManager.java
// public enum WrapType {
// CLAMP,
// REPEAT
// };
// Path: MarsImages/Rajawali/src/main/java/rajawali/materials/TextureInfo.java
import java.nio.ByteBuffer;
import rajawali.materials.TextureManager.CompressionType;
import rajawali.materials.TextureManager.FilterType;
import rajawali.materials.TextureManager.TextureType;
import rajawali.materials.TextureManager.WrapType;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
package rajawali.materials;
/**
* This class contains OpenGL specific texture information.
*
* @author dennis.ippel
*
*/
public class TextureInfo {
/**
* This texture's unique id
*/
protected int mTextureId;
/**
* The type of texture
*
* @see TextureManager.TextureType
*/ | protected TextureType mTextureType; |
OpsLabJPL/MarsImagesAndroid | MarsImages/Rajawali/src/main/java/rajawali/materials/TextureInfo.java | // Path: MarsImages/Rajawali/src/main/java/rajawali/materials/TextureManager.java
// public enum CompressionType {
// NONE,
// ETC1,
// PALETTED,
// THREEDC,
// ATC,
// DXT1,
// PVRTC
// };
//
// Path: MarsImages/Rajawali/src/main/java/rajawali/materials/TextureManager.java
// public enum FilterType{
// NEAREST,
// LINEAR
// };
//
// Path: MarsImages/Rajawali/src/main/java/rajawali/materials/TextureManager.java
// public enum TextureType {
// DIFFUSE,
// BUMP,
// SPECULAR,
// ALPHA,
// FRAME_BUFFER,
// DEPTH_BUFFER,
// LOOKUP,
// CUBE_MAP,
// SPHERE_MAP,
// VIDEO_TEXTURE
// };
//
// Path: MarsImages/Rajawali/src/main/java/rajawali/materials/TextureManager.java
// public enum WrapType {
// CLAMP,
// REPEAT
// };
| import java.nio.ByteBuffer;
import rajawali.materials.TextureManager.CompressionType;
import rajawali.materials.TextureManager.FilterType;
import rajawali.materials.TextureManager.TextureType;
import rajawali.materials.TextureManager.WrapType;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config; | package rajawali.materials;
/**
* This class contains OpenGL specific texture information.
*
* @author dennis.ippel
*
*/
public class TextureInfo {
/**
* This texture's unique id
*/
protected int mTextureId;
/**
* The type of texture
*
* @see TextureManager.TextureType
*/
protected TextureType mTextureType;
protected String mTextureName = "";
/**
* The shader uniform handle for this texture
*/
protected int mUniformHandle = -1;
/**
* Texture width
*/
protected int mWidth;
/**
* Texture height
*/
protected int mHeight;
protected Bitmap mTexture;
protected Bitmap[] mTextures;
protected boolean mMipmap;
protected Config mBitmapConfig;
protected boolean mShouldRecycle;
| // Path: MarsImages/Rajawali/src/main/java/rajawali/materials/TextureManager.java
// public enum CompressionType {
// NONE,
// ETC1,
// PALETTED,
// THREEDC,
// ATC,
// DXT1,
// PVRTC
// };
//
// Path: MarsImages/Rajawali/src/main/java/rajawali/materials/TextureManager.java
// public enum FilterType{
// NEAREST,
// LINEAR
// };
//
// Path: MarsImages/Rajawali/src/main/java/rajawali/materials/TextureManager.java
// public enum TextureType {
// DIFFUSE,
// BUMP,
// SPECULAR,
// ALPHA,
// FRAME_BUFFER,
// DEPTH_BUFFER,
// LOOKUP,
// CUBE_MAP,
// SPHERE_MAP,
// VIDEO_TEXTURE
// };
//
// Path: MarsImages/Rajawali/src/main/java/rajawali/materials/TextureManager.java
// public enum WrapType {
// CLAMP,
// REPEAT
// };
// Path: MarsImages/Rajawali/src/main/java/rajawali/materials/TextureInfo.java
import java.nio.ByteBuffer;
import rajawali.materials.TextureManager.CompressionType;
import rajawali.materials.TextureManager.FilterType;
import rajawali.materials.TextureManager.TextureType;
import rajawali.materials.TextureManager.WrapType;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
package rajawali.materials;
/**
* This class contains OpenGL specific texture information.
*
* @author dennis.ippel
*
*/
public class TextureInfo {
/**
* This texture's unique id
*/
protected int mTextureId;
/**
* The type of texture
*
* @see TextureManager.TextureType
*/
protected TextureType mTextureType;
protected String mTextureName = "";
/**
* The shader uniform handle for this texture
*/
protected int mUniformHandle = -1;
/**
* Texture width
*/
protected int mWidth;
/**
* Texture height
*/
protected int mHeight;
protected Bitmap mTexture;
protected Bitmap[] mTextures;
protected boolean mMipmap;
protected Config mBitmapConfig;
protected boolean mShouldRecycle;
| protected CompressionType mCompressionType; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.