Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public int what ()

public void generate (@NonNull final IJFormatter f)
{
f.print (representation.format (m_nValue));
f.print (representation ().base ().format (m_nValue, new StringBuilder (), representation ()).toString ());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public long what ()

public void generate (@NonNull final IJFormatter f)
{
f.print (representation.format (m_nValue));
f.print (representation ().base ().format (m_nValue, new StringBuilder (), representation ()).toString ());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public abstract class AIntegerRepresented <T extends AIntegerRepresented <T>>
{

@NonNull
protected IntegerRepresentation representation = IntegerRepresentation.DEFAULT;
protected IntegerRepresentation m_aRepresentation = IntegerRepresentation.DEFAULT;

@SuppressWarnings ("unchecked")
protected T self ()
Expand All @@ -22,7 +22,7 @@ protected T self ()
@NonNull
public IntegerRepresentation representation ()
{
return representation;
return m_aRepresentation;
}

/// change the internal representation to the provided one
Expand All @@ -32,7 +32,7 @@ public IntegerRepresentation representation ()
public @NonNull T representation (IntegerRepresentation representation)
{
if (representation != null)
this.representation = representation;
this.m_aRepresentation = representation;
return self ();
}

Expand All @@ -41,39 +41,39 @@ public IntegerRepresentation representation ()
/// @return this
public @NonNull T positiveSign (boolean positiveSign)
{
return representation (representation.positiveSign (positiveSign));
return representation (representation ().positiveSign (positiveSign));
}

/// change the internal representation to use binary base
///
/// @return this
public @NonNull T binary ()
{
return representation (representation.base (EIntegerBase.BINARY));
return representation (representation ().base (EIntegerBase.BINARY));
}

/// change the internal representation to use decimal base
///
/// @return this
public @NonNull T decimal ()
{
return representation (representation.base (EIntegerBase.DECIMAL));
return representation (representation ().base (EIntegerBase.DECIMAL));
}

/// change the internal representation to use hexadecimal base
///
/// @return this
public @NonNull T hexadecimal ()
{
return representation (representation.base (EIntegerBase.HEXADECIMAL));
return representation (representation ().base (EIntegerBase.HEXADECIMAL));
}

/// change the internal representation to use octal base
///
/// @return this
public @NonNull T octal ()
{
return representation (representation.base (EIntegerBase.OCTAL));
return representation (representation ().base (EIntegerBase.OCTAL));
}

/// change the internal representation to use a fixed separator size (the number of character
Expand All @@ -83,7 +83,7 @@ public IntegerRepresentation representation ()
/// @return this
public @NonNull T separatorSize (int size)
{
return representation (representation.separatorSize (size));
return representation (representation ().separatorSize (size));
}

/// change the internal representation to use a fixed separator distance (the maximum number of
Expand All @@ -93,7 +93,7 @@ public IntegerRepresentation representation ()
/// @return this
public @NonNull T separateEvery (int every)
{
return representation (representation.separateEvery (every));
return representation (representation ().separateEvery (every));
}

/// change the internal representation to use a padding value. The padding is not used for decimal
Expand All @@ -102,7 +102,7 @@ public IntegerRepresentation representation ()
/// @return this
public @NonNull T padding (int padding)
{
return representation (representation.padding (padding));
return representation (representation ().padding (padding));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public enum EIntegerBase
}

/// @return sb
public StringBuilder represent (int i,
public StringBuilder format (int i,
StringBuilder sb,
IntegerRepresentation f)
{
Expand All @@ -83,7 +83,7 @@ public StringBuilder represent (int i,
}

/// @return sb
public StringBuilder represent (long l,
public StringBuilder format (long l,
StringBuilder sb,
IntegerRepresentation f)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,18 +199,4 @@ public IntegerRepresentation sufixUpper (boolean suffixUpper)
return suffixUpper == this.suffixUpper ? this : with (ir -> { ir.suffixUpper = suffixUpper; });
}

//
// actual formatting is delegated to the base
//

public String format (int i)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove these sanity methods? Isn't that something you usually like?

@glelouet glelouet Aug 30, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just moved the call ? instead of applying to the Representation, which calls the base with itself as params, I directly call the base with the Representation as param.

This was something you mentionned in the previous PR, but was left off when merging.

https://github.com/phax/jcodemodel/pull/182/changes/BASE..3bdb5451ab1ca63c54468698a14c0049dc0a98b6#diff-27921528c84e44ffe0fa1c30100ce28fa45cbec7042924072abd01196e7eb229R64

{
return base.represent (i, new StringBuilder (), this).toString ();
}

public String format (long l)
{
return base.represent (l, new StringBuilder (), this).toString ();
}

}
Loading