Commit a0b99c3b authored by Ryan Berkheimer's avatar Ryan Berkheimer
Browse files

changed Boolean to bool use in IRecord/RecordUtils (part of overall bugfix to...

changed Boolean to bool use in IRecord/RecordUtils (part of overall bugfix to change Boolean to bool for C/C++ API)
parent 8eeedab0
......@@ -26,14 +26,15 @@ RecordUtils::~RecordUtils()
bool RecordUtils::isValid(struct record *record)
{
return (bool)this->jvm->CallBooleanMethod(record->jrecord, this->isValidMethodId);
jboolean jBoolVal = this->jvm->CallBooleanMethod(record->jrecord, this->isValidMethodId);
bool boolVal = (bool)(jBoolVal != JNI_FALSE);
return boolVal;
}
void RecordUtils::setValid(struct record *record, bool isValid)
{
jobject jBoolVal = jvm->NewObject(this->typeUtils->getBoolClass(), this->typeUtils->createBoolMethod(), (jboolean)isValid);
jboolean jBoolVal = (isValid) ? JNI_TRUE : JNI_FALSE;
this->jvm->CallVoidMethod(record->jrecord, this->setValidMethodId, jBoolVal);
this->jvm->DeleteLocalRef(jBoolVal);
}
struct record *RecordUtils::getCopy(struct record *record)
......@@ -47,7 +48,8 @@ struct record *RecordUtils::getCopy(struct record *record)
bool RecordUtils::hasField(struct record *record, const char *fieldId)
{
jstring jFieldId = this->typeUtils->toJavaString(fieldId);
bool hasJField = (bool)this->jvm->CallBooleanMethod(record->jrecord, this->hasFieldMethodId, jFieldId);
jboolean jBoolVal = this->jvm->CallBooleanMethod(record->jrecord, this->hasFieldMethodId, jFieldId);
bool hasJField = (bool)(jBoolVal != JNI_FALSE);
this->jvm->DeleteLocalRef(jFieldId);
return hasJField;
}
......@@ -92,7 +94,8 @@ struct field *RecordUtils::getField(struct record *record, const char *fieldId)
bool RecordUtils::hasCondition(struct record *record, const char *conditionId)
{
jstring jConditionId = this->typeUtils->toJavaString(conditionId);
bool hasJCondition = (bool)this->jvm->CallBooleanMethod(record->jrecord, this->hasConditionMethodId, jConditionId);
jboolean jBoolVal = this->jvm->CallBooleanMethod(record->jrecord, this->hasConditionMethodId, jConditionId);
bool hasJCondition = (bool)(jBoolVal != JNI_FALSE);
this->jvm->DeleteLocalRef(jConditionId);
return hasJCondition;
}
......@@ -192,11 +195,11 @@ const char *RecordUtils::getMethodSignature(const char *methodName)
{
if (strcmp(methodName, "isValid") == 0)
{
return "()Ljava/lang/Boolean;";
return "()Z";
}
else if (strcmp(methodName, "setValid") == 0)
{
return "(Ljava/lang/Boolean;)V";
return "(Z)V";
}
else if (strcmp(methodName, "getCopy") == 0)
......@@ -209,7 +212,7 @@ const char *RecordUtils::getMethodSignature(const char *methodName)
}
else if (strcmp(methodName, "hasField") == 0)
{
return "(Ljava/lang/String;)Ljava/lang/Boolean;";
return "(Ljava/lang/String;)Z";
}
else if (strcmp(methodName, "getFields") == 0)
{
......@@ -225,7 +228,7 @@ const char *RecordUtils::getMethodSignature(const char *methodName)
}
else if (strcmp(methodName, "hasCondition") == 0)
{
return "(Ljava/lang/String;)Ljava/lang/Boolean;";
return "(Ljava/lang/String;)Z";
}
else if (strcmp(methodName, "getConditions") == 0)
{
......
......@@ -92,9 +92,8 @@ void ResponseUtils::setRecords(struct response *response, struct record_list *re
void ResponseUtils::setComplete(struct response *response, bool isComplete)
{
jobject jBoolVal = jvm->NewObject(this->typeUtils->getBoolClass(), this->typeUtils->createBoolMethod(), (jboolean)isComplete);
jboolean jBoolVal = (isComplete) ? JNI_TRUE : JNI_FALSE;
this->jvm->CallVoidMethod(response->jresponse, this->setCompleteMethodId, jBoolVal);
this->jvm->DeleteLocalRef(jBoolVal);
}
/* Private Methods */
......
......@@ -69,14 +69,14 @@ public interface IRecord {
* their fields defined outside of code, this method may be useful
* for code-level inspection and/or automation.
*/
public Boolean hasField(String fieldId);
public boolean hasField(String fieldId);
/**
* returns a true/false indicating whether the given field (by id/name) exists
* in the record. While all records have their fields defined outside of code,
* this method may be useful for code-level inspection and/or automation.
*/
public Boolean hasCondition(String conditionId);
public boolean hasCondition(String conditionId);
/**
* Sets the given condition to hold the given value. The condition
......@@ -100,11 +100,11 @@ public interface IRecord {
* is abstract, but could typically be used if all conditions are validated against
* all fields.
*/
public Boolean isValid();
public boolean isValid();
/**
* Sets the validity of the record to the passed true/false status.
*/
public void setValid(Boolean status);
public void setValid(boolean status);
}
......@@ -22,7 +22,7 @@ public class SchemaRecord implements IRecord {
private List<IField> fields = null;
private List<ICondition> conditions = null;
private Boolean valid = true;
private boolean valid = true;
public SchemaRecord(final List<Map<String, Object>> fieldMaps, final List<Map<String, Object>> conditionMaps) {
this.initializeFields(fieldMaps);
......@@ -140,11 +140,11 @@ public class SchemaRecord implements IRecord {
}
}
public Boolean hasField(final String fieldId) {
public boolean hasField(final String fieldId) {
return this.fields.stream().filter(field -> field.getId().equals(fieldId)).findFirst().isPresent();
}
public Boolean hasCondition(final String conditionId) {
public boolean hasCondition(final String conditionId) {
return this.conditions.stream().filter(condition -> condition.getId().equals(conditionId)).findFirst()
.isPresent();
}
......@@ -174,11 +174,11 @@ public class SchemaRecord implements IRecord {
return this.conditions.stream().map(condition -> condition.getId()).collect(Collectors.toList());
}
public void setValid(final Boolean valid) {
public void setValid(final boolean valid) {
this.valid = valid;
}
public Boolean isValid() {
public boolean isValid() {
return this.valid;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment