Skip to content

Commit

Permalink
Remove some minor sonar cloud issues
Browse files Browse the repository at this point in the history
  • Loading branch information
fugerit79 committed Sep 16, 2023
1 parent b711503 commit 9a086c0
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class JvfsDataLogicFacade extends JvfsDataLogicFacadeHelper implements or
*
*/
private static final long serialVersionUID = 2818436404285930891L;

private static final JvfsDataLogicFacade INSTANCE = new JvfsDataLogicFacade();

public static JvfsLogicFacade getInstance() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private VersionUtils() {}
* @param name the name of the module to register
* @param className the implementing class for the module
*/
public synchronized static void registerModule( String name, String className ) {
public static synchronized void registerModule( String name, String className ) {
MODULES.setProperty( name , className );
}

Expand All @@ -58,7 +58,7 @@ public synchronized static void registerModule( String name, String className )
*
* @return the module list
*/
public synchronized static Properties getModuleList() {
public static synchronized Properties getModuleList() {
return MODULES;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
import java.util.Properties;

import org.fugerit.java.core.cfg.ConfigException;
import org.fugerit.java.core.cfg.ConfigurableObject;
Expand All @@ -32,7 +31,6 @@
import org.fugerit.java.core.util.PropsIO;
import org.fugerit.java.core.xml.dom.DOMIO;
import org.slf4j.Logger;
import org.w3c.dom.Element;

import lombok.AccessLevel;
import lombok.Getter;
Expand Down Expand Up @@ -72,18 +70,6 @@ private void readObject(java.io.ObjectInputStream in) throws IOException, ClassN

protected static Logger logger = log; // for backward compatibility

/* (non-Javadoc)
* @see org.fugerit.java.core.cfg.ConfigurableObject#configure(java.util.Properties)
*/
@Override
public abstract void configure(Properties props) throws ConfigException;

/* (non-Javadoc)
* @see org.fugerit.java.core.cfg.ConfigurableObject#configure(org.w3c.dom.Element)
*/
@Override
public abstract void configure(Element tag) throws ConfigException;

/* (non-Javadoc)
* @see org.fugerit.java.core.cfg.ConfigurableObject#configureProperties(java.io.InputStream)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@
import java.util.function.Consumer;

import org.fugerit.java.core.cfg.ConfigException;
import org.fugerit.java.core.log.LogFacade;
import org.w3c.dom.Element;

import lombok.extern.slf4j.Slf4j;

/**
* <p>Base class for implementations of ConfigurableObject supporting only
* the <code>configure(Element)</code> method.
Expand All @@ -35,6 +36,7 @@
* @author Fugerit
*
*/
@Slf4j
public abstract class XMLConfigurableObject extends AbstractConfigurableObject {

/*
Expand All @@ -52,7 +54,7 @@ public void configure(Element tag) throws ConfigException {
};
}

public static final XMLConfigurableObject DO_NOTHING = newXMLConfigurableObject( e -> { LogFacade.getLog().debug( "do nothing impl , param element : {}" , e); } );
public static final XMLConfigurableObject DO_NOTHING = newXMLConfigurableObject( e -> log.debug( "do nothing impl , param element : {}" , e) );

/* (non-Javadoc)
* @see org.fugerit.java.core.cfg.ConfigurableObject#configure(java.util.Properties)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class ConfigStoreProps extends ConfigStoreDefault {

private static final String KEY_ENTRY_NAMES = "_"+ConfigStoreProps.class.getSimpleName()+"_ENTRY_NAMES";

public Properties configProps;
private Properties configProps;

private ConfigStoreProps(Properties configProps) {
this.configProps = configProps;
Expand Down Expand Up @@ -71,7 +71,7 @@ public ConfigStoreMap remove(String name) {
private Set<String> getNameSet() {
String names = this.configProps.getProperty( KEY_ENTRY_NAMES, "" );
Set<String> res = Arrays.asList( names.split( SEP_NAMES ) ).stream()
.filter( v -> StringUtils.isNotEmpty( v ) )
.filter( StringUtils::isNotEmpty )
.collect( Collectors.toCollection( LinkedHashSet::new ) );
logger.debug( "getNameSet() names '{}' -> {}", names, res );
return res;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public T createHelper( FactoryType factoryType ) throws ConfigException {
}

public static <T> FactoryTypeHelper<T> newInstance( Class<? extends T> ct ) {
return new FactoryTypeHelper<T>( ct );
return new FactoryTypeHelper<>( ct );
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,12 @@ public GenericListCatalogConfig() {
* @param attTagData attribute name to use for data entry
*/
public GenericListCatalogConfig( String attTagDataList, String attTagData ) {
this.dataMap = new HashMap<String, Collection<T>>();
this.dataMap = new HashMap<>();
this.attTagDataList = attTagDataList;
this.attTagData = attTagData;
this.generalProps = new Properties();
this.orderedId = new ConcurrentSkipListSet<String>();
this.entryIdCheck = new HashSet<String>();
this.orderedId = new ConcurrentSkipListSet<>();
this.entryIdCheck = new HashSet<>();
}

/**
Expand Down Expand Up @@ -310,9 +310,9 @@ protected Collection<T> newCollection( Object typeSample, String listType, Eleme
throw new ConfigException( e );
}
} else if ( typeSample instanceof KeyObject<?> ) {
c = new ListMapConfig<T>();
c = new ListMapConfig<>();
} else {
c = new ArrayList<T>();
c = new ArrayList<>();
}
if ( c instanceof ListMapConfig ) {
((ListMapConfig<T>)c).initFromElementAttributes( current );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ public class ListMapConfig<T> extends ListMapStringKey<T> implements IdConfigTyp
*/
private static final long serialVersionUID = -1229366094851449578L;

@Override
public int hashCode() {
// super class implementation is ok
return super.hashCode();
}

@Override
public boolean equals(Object o) {
// super class implementation is ok - ListMapConfig is equals if all contained elements are equals
return super.equals(o);
}

private Properties config = new Properties();

public ListMapConfig() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CodingErrorAction;
import java.util.Arrays;

import lombok.extern.slf4j.Slf4j;

Expand Down Expand Up @@ -65,10 +66,7 @@ public static boolean checkEncoding( final InputStream is, final String encoding
totalSize+= read;
byte[] checkData = buffer;
if ( read != buffer.length ) {
checkData = new byte[read];
for ( int k=0; k<read; k++ ) {
checkData[k] = buffer[k];
}
checkData = Arrays.copyOf( buffer , read );
}
result = checkEncoding( checkData , encoding );
read = is.read( buffer );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class CfConfig {
*
*/
public CfConfig() {
this.cfMap = new HashMap<String, ConnectionFactory>();
this.cfMap = new HashMap<>();
}

private Map<String, ConnectionFactory> cfMap;
Expand Down

0 comments on commit 9a086c0

Please sign in to comment.