rename helper methods

This commit is contained in:
Vukašin Stepanović
2023-02-15 12:52:59 +00:00
parent bfcdb397ad
commit 935519ced5
133 changed files with 858 additions and 1044 deletions

View File

@@ -182,18 +182,18 @@ pub trait UPCEANReader: OneDReader {
let end = endRange[1];
let quietEnd = end + (end - endRange[0]);
if quietEnd >= row.getSize() || !row.isRange(end, quietEnd, false)? {
return Err(Exceptions::notFoundEmpty());
return Err(Exceptions::notFound);
}
let resultString = result;
// UPC/EAN should never be less than 8 chars anyway
if resultString.chars().count() < 8 {
return Err(Exceptions::formatEmpty());
return Err(Exceptions::format);
}
if !self.checkChecksum(&resultString)? {
return Err(Exceptions::checksumEmpty());
return Err(Exceptions::checksum);
}
let left = (startGuardRange[1] + startGuardRange[0]) as f32 / 2.0;
@@ -241,7 +241,7 @@ pub trait UPCEANReader: OneDReader {
}
}
if !valid {
return Err(Exceptions::notFoundEmpty());
return Err(Exceptions::notFound);
}
}
@@ -292,7 +292,7 @@ pub trait UPCEANReader: OneDReader {
let char_in_question = s
.chars()
.nth(length - 1)
.ok_or(Exceptions::indexOutOfBoundsEmpty())?;
.ok_or(Exceptions::indexOutOfBounds)?;
let check = char_in_question.is_ascii_digit();
let check_against = &s[..length - 1]; //s.subSequence(0, length - 1);
@@ -300,9 +300,7 @@ pub trait UPCEANReader: OneDReader {
Ok(calculated_checksum
== if check {
char_in_question
.to_digit(10)
.ok_or(Exceptions::parseEmpty())?
char_in_question.to_digit(10).ok_or(Exceptions::parse)?
} else {
u32::MAX
})
@@ -317,10 +315,10 @@ pub trait UPCEANReader: OneDReader {
let digit = (s
.chars()
.nth(i as usize)
.ok_or(Exceptions::indexOutOfBoundsEmpty())? as i32)
.ok_or(Exceptions::indexOutOfBounds)? as i32)
- ('0' as i32);
if !(0..=9).contains(&digit) {
return Err(Exceptions::formatEmpty());
return Err(Exceptions::format);
}
sum += digit;
@@ -333,10 +331,10 @@ pub trait UPCEANReader: OneDReader {
let digit = (s
.chars()
.nth(i as usize)
.ok_or(Exceptions::indexOutOfBoundsEmpty())? as i32)
.ok_or(Exceptions::indexOutOfBounds)? as i32)
- ('0' as i32);
if !(0..=9).contains(&digit) {
return Err(Exceptions::formatEmpty());
return Err(Exceptions::format);
}
sum += digit;
@@ -423,7 +421,7 @@ pub trait UPCEANReader: OneDReader {
}
}
Err(Exceptions::notFoundEmpty())
Err(Exceptions::notFound)
}
/**
@@ -460,7 +458,7 @@ pub trait UPCEANReader: OneDReader {
if bestMatch >= 0 {
Ok(bestMatch as usize)
} else {
Err(Exceptions::notFoundEmpty())
Err(Exceptions::notFound)
}
}